├── .editorconfig ├── .github ├── dependabot.OLD.NOT-CURRENTLY-IN-USE.yml └── workflows │ ├── build.yml │ ├── codeql.yml │ ├── dependency-review.yml │ ├── manual-release.yml │ ├── on-push-to-main-branch.yml │ ├── on-push-to-release-branch.yml │ ├── retry-tests.yml │ └── update-example-deps.yml ├── .gitignore ├── .vscode └── client-sdk-javascript.code-workspace ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── README.template.md ├── examples ├── README.md ├── README.template.md ├── cloudflare-workers │ ├── README.md │ ├── README.template.md │ ├── http-api │ │ ├── .dev.vars │ │ ├── .editorconfig │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── README.template.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ │ └── worker.ts │ │ ├── tsconfig.json │ │ └── wrangler.toml │ └── web-sdk │ │ ├── .dev.vars │ │ ├── .editorconfig │ │ ├── .prettierrc │ │ ├── README.md │ │ ├── README.template.md │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ └── worker.ts │ │ ├── tsconfig.json │ │ └── wrangler.toml ├── deno │ ├── README.md │ ├── README.template.md │ ├── http-api │ │ ├── .env.example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── README.template.md │ │ ├── deno.json │ │ └── index.ts │ └── web-sdk │ │ ├── .env.example │ │ ├── .gitignore │ │ ├── README.md │ │ ├── README.template.md │ │ ├── deno.json │ │ └── index.ts ├── fastly-compute │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc.json │ ├── README.md │ ├── README.template.md │ ├── fastly.toml │ ├── package-lock.json │ ├── package.json │ ├── secrets.json.example │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── nodejs │ ├── README.md │ ├── README.template.md │ ├── access-control │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── README.template.md │ │ ├── access-control.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ ├── aws │ │ ├── README.md │ │ ├── README.template.md │ │ ├── eventbridge │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── README.template.md │ │ │ ├── cliApp │ │ │ │ ├── .eslintignore │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── .gitignore │ │ │ │ ├── .prettierrc.json │ │ │ │ ├── README.md │ │ │ │ ├── README.template.md │ │ │ │ ├── cli-demo.ts │ │ │ │ ├── jest.config.js │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ ├── tsconfig.json │ │ │ │ └── utils │ │ │ │ │ ├── dynamodb.ts │ │ │ │ │ ├── helper.ts │ │ │ │ │ └── momento.ts │ │ │ ├── deploy-stack.sh │ │ │ ├── infrastructure │ │ │ │ ├── .gitignore │ │ │ │ ├── .npmignore │ │ │ │ ├── bin │ │ │ │ │ └── eventbridge.ts │ │ │ │ ├── cdk.json │ │ │ │ ├── jest.config.js │ │ │ │ ├── lib │ │ │ │ │ └── eventbridge-stack.ts │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ └── tsconfig.json │ │ │ ├── momento-eventbridge.drawio.png │ │ │ ├── run-bash-cli-app.sh │ │ │ ├── run-typescript-cli-app.sh │ │ │ ├── run-webapp.sh │ │ │ ├── subscribe-to-topic.sh │ │ │ └── webapp │ │ │ │ ├── .eslintrc.cjs │ │ │ │ ├── .gitignore │ │ │ │ ├── .prettierrc.json │ │ │ │ ├── README.md │ │ │ │ ├── README.template.md │ │ │ │ ├── index.html │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ ├── postcss.config.cjs │ │ │ │ ├── public │ │ │ │ └── favicon.ico │ │ │ │ ├── src │ │ │ │ ├── App.css │ │ │ │ ├── App.tsx │ │ │ │ ├── assets │ │ │ │ │ ├── aws-dynamodb.svg │ │ │ │ │ ├── aws-eventbridge.svg │ │ │ │ │ ├── momento-logo-mint.svg │ │ │ │ │ ├── momento-mark-mint.svg │ │ │ │ │ ├── momento-service-arch-icon-Cache.svg │ │ │ │ │ └── momento-service-arch-icon-Topics.svg │ │ │ │ ├── components │ │ │ │ │ ├── CacheModal.tsx │ │ │ │ │ ├── CreateRecordForm.tsx │ │ │ │ │ ├── DeleteRecordForm.tsx │ │ │ │ │ ├── DescribeCache.tsx │ │ │ │ │ ├── InfoModal.tsx │ │ │ │ │ └── Topic.tsx │ │ │ │ ├── index.css │ │ │ │ ├── main.tsx │ │ │ │ ├── svgs │ │ │ │ │ ├── arrow-down.tsx │ │ │ │ │ ├── arrow-left.tsx │ │ │ │ │ ├── arrow-right.tsx │ │ │ │ │ ├── ban-circle.tsx │ │ │ │ │ ├── check-circle.tsx │ │ │ │ │ ├── corner-left-down.tsx │ │ │ │ │ ├── corner-right-down.tsx │ │ │ │ │ └── help.tsx │ │ │ │ ├── utils │ │ │ │ │ ├── dynamodb.ts │ │ │ │ │ ├── helper.ts │ │ │ │ │ ├── momento-web.ts │ │ │ │ │ └── toast.tsx │ │ │ │ └── vite-env.d.ts │ │ │ │ ├── store │ │ │ │ └── controlplane-store.ts │ │ │ │ ├── tailwind.config.cjs │ │ │ │ ├── tsconfig.json │ │ │ │ ├── tsconfig.node.json │ │ │ │ └── vite.config.ts │ │ ├── lambda-examples │ │ │ ├── README.md │ │ │ ├── README.template.md │ │ │ ├── advanced-compression-cdk │ │ │ │ ├── .gitignore │ │ │ │ ├── .npmignore │ │ │ │ ├── README.template.md │ │ │ │ ├── infrastructure │ │ │ │ │ ├── .eslintignore │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── .npmrc │ │ │ │ │ ├── .prettierrc.json │ │ │ │ │ ├── bin │ │ │ │ │ │ └── advanced-compression-cdk.ts │ │ │ │ │ ├── cdk.json │ │ │ │ │ ├── lib │ │ │ │ │ │ └── advanced-compression-cdk-stack.ts │ │ │ │ │ ├── package-lock.json │ │ │ │ │ ├── package.json │ │ │ │ │ └── tsconfig.json │ │ │ │ └── src │ │ │ │ │ ├── lambda │ │ │ │ │ ├── .eslintignore │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── .npmrc │ │ │ │ │ ├── .prettierrc.json │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── package-lock.json │ │ │ │ │ ├── package.json │ │ │ │ │ └── tsconfig.json │ │ │ │ │ └── zstd-layer │ │ │ │ │ └── nodejs │ │ │ │ │ ├── .npmrc │ │ │ │ │ ├── package-lock.json │ │ │ │ │ └── package.json │ │ │ ├── advanced-compression │ │ │ │ ├── .gitignore │ │ │ │ ├── Dockerfile │ │ │ │ ├── README.md │ │ │ │ ├── README.template.md │ │ │ │ ├── esbuild.ts │ │ │ │ ├── nodemon.json │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ ├── postbuild.ts │ │ │ │ ├── src │ │ │ │ │ └── index.ts │ │ │ │ ├── template.yaml │ │ │ │ └── tsconfig.json │ │ │ ├── cloudwatch-metrics │ │ │ │ ├── README.md │ │ │ │ ├── README.template.md │ │ │ │ ├── docker │ │ │ │ │ ├── Dockerfile │ │ │ │ │ └── ecs-code │ │ │ │ │ │ ├── .eslintignore │ │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ ├── .npmignore │ │ │ │ │ │ ├── .prettierrc.json │ │ │ │ │ │ ├── index.ts │ │ │ │ │ │ ├── package-lock.json │ │ │ │ │ │ ├── package.json │ │ │ │ │ │ └── tsconfig.json │ │ │ │ ├── infrastructure │ │ │ │ │ ├── .eslintignore │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── .npmignore │ │ │ │ │ ├── .prettierrc.json │ │ │ │ │ ├── bin │ │ │ │ │ │ └── infrastructure.ts │ │ │ │ │ ├── cdk.json │ │ │ │ │ ├── jest.config.js │ │ │ │ │ ├── lib │ │ │ │ │ │ └── momento-metrics-stack.ts │ │ │ │ │ ├── package-lock.json │ │ │ │ │ ├── package.json │ │ │ │ │ └── tsconfig.json │ │ │ │ └── lambda │ │ │ │ │ ├── .eslintignore │ │ │ │ │ ├── .eslintrc.json │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── .npmignore │ │ │ │ │ ├── .prettierrc.json │ │ │ │ │ ├── handler.ts │ │ │ │ │ ├── jest.config.js │ │ │ │ │ ├── package-lock.json │ │ │ │ │ ├── package.json │ │ │ │ │ └── tsconfig.json │ │ │ └── simple-get │ │ │ │ ├── README.md │ │ │ │ ├── README.template.md │ │ │ │ ├── infrastructure │ │ │ │ ├── .eslintignore │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── .gitignore │ │ │ │ ├── .npmignore │ │ │ │ ├── .prettierrc.json │ │ │ │ ├── bin │ │ │ │ │ └── infrastructure.ts │ │ │ │ ├── cdk.json │ │ │ │ ├── jest.config.js │ │ │ │ ├── lib │ │ │ │ │ └── simple-get-stack.ts │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ └── tsconfig.json │ │ │ │ └── lambda │ │ │ │ └── simple-get │ │ │ │ ├── .eslintignore │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── .gitignore │ │ │ │ ├── .npmignore │ │ │ │ ├── .prettierrc.json │ │ │ │ ├── handler.ts │ │ │ │ ├── jest.config.js │ │ │ │ ├── package-lock.json │ │ │ │ ├── package.json │ │ │ │ └── tsconfig.json │ │ ├── package-lock.json │ │ └── secrets-manager │ │ │ ├── .eslintignore │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── .npmignore │ │ │ ├── .prettierrc.json │ │ │ ├── README.md │ │ │ ├── README.template.md │ │ │ ├── doc-example-files │ │ │ ├── README.md │ │ │ └── doc-examples-js-aws-secrets.ts │ │ │ ├── jest.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── tsconfig.json │ ├── cache │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.ja.md │ │ ├── README.md │ │ ├── README.template.md │ │ ├── advanced.ts │ │ ├── basic.ts │ │ ├── batchutils.ts │ │ ├── dictionary.ts │ │ ├── doc-example-files │ │ │ ├── README.md │ │ │ ├── cheat-sheet-main.ts │ │ │ ├── collection-ttl.ts │ │ │ ├── config-and-error-handling.ts │ │ │ ├── doc-examples-js-apis.ts │ │ │ ├── leaderboard-ids.ts │ │ │ ├── myfile.json │ │ │ ├── patterns.ts │ │ │ └── working-with-files.ts │ │ ├── jest.config.js │ │ ├── leaderboard.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── readme.ts │ │ ├── sharded-dictionary.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── collections.ts │ │ │ └── time.ts │ ├── compression-zstd │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── README.template.md │ │ ├── compression.ts │ │ ├── jest.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ ├── compression │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── README.template.md │ │ ├── compression.ts │ │ ├── doc-example-files │ │ │ └── doc-examples-js-apis.ts │ │ ├── jest.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ └── tsconfig.json │ ├── get-set-batch-perf-test │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── jest.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── perf-test.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── cache.ts │ │ │ ├── perf-test-options.ts │ │ │ └── perf-test-utils.ts │ ├── load-gen │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.ja.md │ │ ├── README.md │ │ ├── README.template.md │ │ ├── jest.config.js │ │ ├── load-gen.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── request-coalescing.ts │ │ ├── tsconfig.json │ │ └── utils │ │ │ ├── cache.ts │ │ │ ├── collections.ts │ │ │ ├── load-gen-statistics-calculator.ts │ │ │ ├── load-gen.ts │ │ │ ├── momento-client-with-coalescing.ts │ │ │ └── time.ts │ ├── mongodb-examples │ │ └── simple-read-aside │ │ │ ├── .eslintrc.json │ │ │ ├── .prettierrc.json │ │ │ ├── README.md │ │ │ ├── jest.config.ts │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ ├── src │ │ │ ├── lib │ │ │ │ └── getClientFunctions.ts │ │ │ └── read-aside-momento-mongo.ts │ │ │ ├── test │ │ │ └── wrapper.test.ts │ │ │ └── tsconfig.json │ ├── observability │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.ja.md │ │ ├── README.md │ │ ├── README.template.md │ │ ├── advanced-logging.ts │ │ ├── config │ │ │ └── prometheus.yml │ │ ├── doc-example-files │ │ │ ├── README.md │ │ │ └── doc-examples-js-apis.ts │ │ ├── docker-compose.yml │ │ ├── example-metric-middleware.ts │ │ ├── grafana │ │ │ ├── dashboards │ │ │ │ └── scalar.json │ │ │ └── provisioning │ │ │ │ ├── dashboards │ │ │ │ └── dashboards.yml │ │ │ │ └── datasources │ │ │ │ └── datasource.yml │ │ ├── jest.config.js │ │ ├── observability.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── pino-logger.ts │ │ ├── resources │ │ │ ├── grafana_screenshot.png │ │ │ └── zipkin_screenshot.png │ │ ├── tsconfig.json │ │ └── utils │ │ │ └── instrumentation.ts │ ├── rate-limiter │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .prettierrc.json │ │ ├── README.md │ │ ├── README.template.md │ │ ├── doc-examples-files │ │ │ └── doc-examples.ts │ │ ├── metrics.ts │ │ ├── momento-rate-limiter.ts │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── rate-limiter.ts │ │ ├── service.ts │ │ ├── tsconfig.json │ │ └── worker.ts │ ├── token-vending-machine │ │ ├── README.md │ │ ├── README.template.md │ │ ├── infrastructure │ │ │ ├── .eslintignore │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── .npmignore │ │ │ ├── .prettierrc.json │ │ │ ├── bin │ │ │ │ └── infrastructure.ts │ │ │ ├── cdk.json │ │ │ ├── jest.config.js │ │ │ ├── lib │ │ │ │ └── token-vending-machine-stack.ts │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ └── lambda │ │ │ ├── authorizer │ │ │ ├── authorizer.ts │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── tsconfig.json │ │ │ └── token-vending-machine │ │ │ ├── .eslintignore │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── .npmignore │ │ │ ├── .prettierrc.json │ │ │ ├── config.ts │ │ │ ├── handler.ts │ │ │ ├── jest.config.js │ │ │ ├── package-lock.json │ │ │ ├── package.json │ │ │ └── tsconfig.json │ └── topics │ │ ├── .eslintignore │ │ ├── .eslintrc.json │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── .prettierrc.json │ │ ├── README.ja.md │ │ ├── README.md │ │ ├── README.template.md │ │ ├── doc-example-files │ │ └── cheat-sheet-main.ts │ │ ├── jest.config.js │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── topic-publish.ts │ │ ├── topic-refresh-token.ts │ │ ├── topic-subscribe.ts │ │ ├── tsconfig.json │ │ └── utils │ │ └── cache.ts └── web │ ├── README.md │ ├── README.template.md │ ├── cache │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .npmignore │ ├── .npmrc │ ├── .prettierrc.json │ ├── README.ja.md │ ├── README.md │ ├── README.template.md │ ├── advanced.ts │ ├── basic.ts │ ├── dictionary.ts │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── readme.ts │ ├── refresh-disposable-tokens.ts │ ├── tsconfig.json │ └── utils │ │ ├── cache.ts │ │ ├── collections.ts │ │ ├── jsdom.ts │ │ └── time.ts │ ├── nextjs-chat │ ├── .eslintrc.js │ ├── .gitignore │ ├── .prettierrc.json │ ├── README.md │ ├── README.template.md │ ├── env.d.ts │ ├── next.config.js │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.js │ ├── public │ │ └── next.svg │ ├── src │ │ ├── app │ │ │ ├── api │ │ │ │ ├── auth │ │ │ │ │ └── [...nextauth] │ │ │ │ │ │ └── route.ts │ │ │ │ └── momento │ │ │ │ │ └── token │ │ │ │ │ ├── config.ts │ │ │ │ │ └── route.ts │ │ │ ├── favicon.ico │ │ │ ├── globals.css │ │ │ ├── layout.tsx │ │ │ ├── next-auth-provider.tsx │ │ │ ├── page.tsx │ │ │ └── pages │ │ │ │ └── chat-room.tsx │ │ └── utils │ │ │ └── momento-web.ts │ ├── tailwind.config.js │ └── tsconfig.json │ ├── topics │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .gitignore │ ├── .npmignore │ ├── .npmrc │ ├── .prettierrc.json │ ├── README.ja.md │ ├── README.md │ ├── README.template.md │ ├── basic.ts │ ├── jest.config.js │ ├── package-lock.json │ ├── package.json │ ├── readme.ts │ ├── tsconfig.json │ └── utils │ │ └── jsdom.ts │ └── vite-chat-app │ ├── .env.development │ ├── .eslintignore │ ├── .eslintrc.cjs │ ├── .gitignore │ ├── README.md │ ├── README.template.md │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.cjs │ ├── public │ └── favicon.ico │ ├── src │ ├── App.css │ ├── App.tsx │ ├── assets │ │ └── react.svg │ ├── components │ │ └── chat-room.tsx │ ├── env.d.ts │ ├── index.css │ ├── main.tsx │ ├── utils │ │ ├── momento-web.ts │ │ └── refreshing-topic-client.ts │ └── vite-env.d.ts │ ├── tailwind.config.cjs │ ├── tsconfig.json │ ├── tsconfig.node.json │ └── vite.config.ts ├── packages ├── client-sdk-nodejs-compression-zstd │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── README.md │ ├── README.template.md │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── compressor-factory.ts │ │ ├── index.ts │ │ └── internal │ │ │ └── compression │ │ │ └── zstd-compression.ts │ ├── test │ │ ├── integration │ │ │ ├── compression.test.ts │ │ │ └── integration-setup.ts │ │ └── unit │ │ │ └── placeholder.test.ts │ └── tsconfig.json ├── client-sdk-nodejs-compression │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── README.md │ ├── README.template.md │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── compressor-factory.ts │ │ ├── index.ts │ │ └── internal │ │ │ └── compression │ │ │ └── gzip-compression.ts │ ├── test │ │ ├── integration │ │ │ ├── compression.test.ts │ │ │ └── integration-setup.ts │ │ └── unit │ │ │ └── placeholder.test.ts │ └── tsconfig.json ├── client-sdk-nodejs │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── Makefile │ ├── README.md │ ├── README.template.md │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── auth-client-props.ts │ │ ├── auth-client.ts │ │ ├── batchutils │ │ │ ├── batch-functions.ts │ │ │ └── batch-props.ts │ │ ├── cache-client-props.ts │ │ ├── cache-client.ts │ │ ├── config │ │ │ ├── auth-client-configuration.ts │ │ │ ├── auth-client-configurations.ts │ │ │ ├── compression │ │ │ │ └── compression.ts │ │ │ ├── configuration.ts │ │ │ ├── configurations.ts │ │ │ ├── leaderboard-configuration.ts │ │ │ ├── leaderboard-configurations.ts │ │ │ ├── logging │ │ │ │ └── default-momento-logger.ts │ │ │ ├── middleware │ │ │ │ ├── cache-request-logging.ts │ │ │ │ ├── example-async-middleware.ts │ │ │ │ ├── experimental-active-request-count-middleware.ts │ │ │ │ ├── experimental-event-loop-perf-middleware.ts │ │ │ │ ├── experimental-garbage-collection-middleware.ts │ │ │ │ ├── experimental-metrics-csv-middleware.ts │ │ │ │ ├── experimental-metrics-logging-middleware.ts │ │ │ │ ├── experimental-middleware-factory.ts │ │ │ │ ├── experimental-momento-local-test-config-middleware.ts │ │ │ │ ├── impl │ │ │ │ │ └── experimental-metrics-middleware.ts │ │ │ │ ├── middleware.ts │ │ │ │ └── request-logging-middleware.ts │ │ │ ├── retry │ │ │ │ ├── default-eligibility-strategy.ts │ │ │ │ ├── eligibility-strategy.ts │ │ │ │ ├── exponential-backoff-retry-strategy.ts │ │ │ │ ├── fixed-count-retry-strategy.ts │ │ │ │ ├── fixed-timeout-retry-strategy.ts │ │ │ │ ├── momento-error-code-metadata-converter.ts │ │ │ │ ├── momento-rpc-method.ts │ │ │ │ ├── no-retry-strategy.ts │ │ │ │ ├── retry-strategy.ts │ │ │ │ └── storage-default-eligibility-strategy.ts │ │ │ ├── storage-configuration.ts │ │ │ ├── storage-configurations.ts │ │ │ ├── topic-configuration.ts │ │ │ ├── topic-configurations.ts │ │ │ └── transport │ │ │ │ ├── cache │ │ │ │ ├── grpc-configuration.ts │ │ │ │ ├── index.ts │ │ │ │ └── transport-strategy.ts │ │ │ │ ├── storage │ │ │ │ ├── grpc-configuration.ts │ │ │ │ ├── index.ts │ │ │ │ └── transport-strategy.ts │ │ │ │ └── topics │ │ │ │ ├── grpc-configuration.ts │ │ │ │ ├── index.ts │ │ │ │ └── transport-strategy.ts │ │ ├── errors │ │ │ ├── cache-service-error-mapper.ts │ │ │ └── compression-error.ts │ │ ├── index.ts │ │ ├── internal │ │ │ ├── auth-client-all-props.ts │ │ │ ├── cache-client-all-props.ts │ │ │ ├── cache-control-client.ts │ │ │ ├── cache-data-client.ts │ │ │ ├── grpc │ │ │ │ ├── grpc-channel-options.ts │ │ │ │ ├── grpc-client-wrapper.ts │ │ │ │ ├── headers-interceptor.ts │ │ │ │ ├── idle-grpc-client-wrapper.ts │ │ │ │ ├── middlewares-interceptor.ts │ │ │ │ └── retry-interceptor.ts │ │ │ ├── internal-auth-client.ts │ │ │ ├── leaderboard-client-all-props.ts │ │ │ ├── leaderboard-data-client.ts │ │ │ ├── leaderboard.ts │ │ │ ├── middleware │ │ │ │ └── in-flight-request-count-middleware.ts │ │ │ ├── ping-client.ts │ │ │ ├── pubsub-client.ts │ │ │ ├── storage-client-all-props.ts │ │ │ ├── storage-control-client.ts │ │ │ ├── storage-data-client.ts │ │ │ ├── topic-client-all-props.ts │ │ │ ├── utils.ts │ │ │ ├── vendor │ │ │ │ └── printf │ │ │ │ │ ├── README.md │ │ │ │ │ ├── printf.d.ts │ │ │ │ │ └── printf.js │ │ │ └── webhook-client.ts │ │ ├── leaderboard-client-props.ts │ │ ├── preview-leaderboard-client.ts │ │ ├── preview-storage-client.ts │ │ ├── storage-client-props.ts │ │ ├── topic-client-props.ts │ │ └── topic-client.ts │ ├── test │ │ ├── integration │ │ │ ├── cache │ │ │ │ ├── batchutils.test.ts │ │ │ │ ├── cache-client-close.test.ts │ │ │ │ ├── client-timeout.test.ts │ │ │ │ └── large-messages.test.ts │ │ │ ├── client-constructor-default-configs.test.ts │ │ │ ├── integration-setup.ts │ │ │ ├── retry │ │ │ │ ├── exponential-backoff-retry-strategy.test.ts │ │ │ │ ├── fixed-count-retry-strategy.test.ts │ │ │ │ ├── fixed-timeout-retry-strategy.test.ts │ │ │ │ ├── topic-client-retry.test.ts │ │ │ │ └── topic-subscribe.test.ts │ │ │ └── shared │ │ │ │ ├── auth │ │ │ │ └── auth-client.test.ts │ │ │ │ ├── cache │ │ │ │ ├── batch-get-set.test.ts │ │ │ │ ├── create-delete-list-cache.test.ts │ │ │ │ ├── dictionary.test.ts │ │ │ │ ├── get-set-delete.test.ts │ │ │ │ ├── item-get-ttl.test.ts │ │ │ │ ├── item-get-type.test.ts │ │ │ │ ├── keys-exist.test.ts │ │ │ │ ├── list.test.ts │ │ │ │ ├── replica-reads.test.ts │ │ │ │ ├── set.test.ts │ │ │ │ ├── sorted-set.test.ts │ │ │ │ └── update-ttl.test.ts │ │ │ │ ├── http │ │ │ │ └── http-apis.test.ts │ │ │ │ ├── leaderboard │ │ │ │ └── leaderboard.test.ts │ │ │ │ └── topics │ │ │ │ └── topic-client.test.ts │ │ ├── momento-local-middleware.ts │ │ ├── test-retry-metrics-collector.ts │ │ └── unit │ │ │ ├── auth-client.test.ts │ │ │ ├── cache-client.test.ts │ │ │ ├── cache-service-error-mapper.test.ts │ │ │ ├── config │ │ │ ├── configuration.test.ts │ │ │ ├── middleware │ │ │ │ ├── cache-request-logging.test.ts │ │ │ │ └── experimental-momento-local-test-config-middleware.test.ts │ │ │ ├── retry │ │ │ │ └── default-eligibility-strategy.test.ts │ │ │ └── transport │ │ │ │ └── transport-strategy.test.ts │ │ │ ├── grpc │ │ │ └── idle-grpc-client-wrapper.test.ts │ │ │ ├── momento-rpc-method.test.ts │ │ │ ├── test-retry-metrics-collector.test.ts │ │ │ └── test-retry-metrics-middleware.test.ts │ └── tsconfig.json ├── client-sdk-web │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── Makefile │ ├── README.md │ ├── README.template.md │ ├── jest.config.ts │ ├── jest.setup.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── auth-client-props.ts │ │ ├── auth-client.ts │ │ ├── cache-client-props.ts │ │ ├── cache-client.ts │ │ ├── config │ │ │ ├── configuration.ts │ │ │ ├── configurations.ts │ │ │ ├── leaderboard-configuration.ts │ │ │ ├── leaderboard-configurations.ts │ │ │ ├── logging │ │ │ │ └── default-momento-logger.ts │ │ │ ├── middleware │ │ │ │ ├── experimental-request-logging-middleware.ts │ │ │ │ └── middleware.ts │ │ │ ├── storage-configuration.ts │ │ │ ├── storage-configurations.ts │ │ │ ├── topic-configuration.ts │ │ │ ├── topic-configurations.ts │ │ │ └── transport │ │ │ │ ├── grpc-configuration.ts │ │ │ │ ├── index.ts │ │ │ │ └── transport-strategy.ts │ │ ├── errors │ │ │ └── cache-service-error-mapper.ts │ │ ├── index.ts │ │ ├── internal │ │ │ ├── auth-client-all-props.ts │ │ │ ├── auth-client.ts │ │ │ ├── cache-client-all-props.ts │ │ │ ├── cache-control-client.ts │ │ │ ├── cache-data-client.ts │ │ │ ├── client-metadata-provider.ts │ │ │ ├── grpc │ │ │ │ ├── headers-interceptor.ts │ │ │ │ └── middlewares-interceptor.ts │ │ │ ├── leaderboard-client-all-props.ts │ │ │ ├── leaderboard-data-client.ts │ │ │ ├── leaderboard.ts │ │ │ ├── ping-client.ts │ │ │ ├── pubsub-client.ts │ │ │ ├── storage-client-all-props.ts │ │ │ ├── storage-control-client.ts │ │ │ ├── storage-data-client.ts │ │ │ ├── topic-client-all-props.ts │ │ │ └── webhook-client.ts │ │ ├── leaderboard-client-props.ts │ │ ├── preview-leaderboard-client.ts │ │ ├── preview-storage-client.ts │ │ ├── storage-client-props.ts │ │ ├── topic-client-props.ts │ │ ├── topic-client.ts │ │ └── utils │ │ │ ├── auth.ts │ │ │ └── web-client-utils.ts │ ├── test │ │ ├── integration │ │ │ ├── CustomHappyDomEnv.js │ │ │ ├── client-constructor-default-configs.test.ts │ │ │ ├── integration-setup.ts │ │ │ ├── internal │ │ │ │ └── ping.test.ts │ │ │ └── shared │ │ │ │ ├── auth │ │ │ │ └── auth-client.test.ts │ │ │ │ ├── cache │ │ │ │ ├── batch-get-set.test.ts │ │ │ │ ├── create-delete-list-cache.test.ts │ │ │ │ ├── dictionary.test.ts │ │ │ │ ├── get-set-delete.test.ts │ │ │ │ ├── item-get-ttl.test.ts │ │ │ │ ├── item-get-type.test.ts │ │ │ │ ├── keys-exist.test.ts │ │ │ │ ├── list.test.ts │ │ │ │ ├── replica-reads.test.ts │ │ │ │ ├── set.test.ts │ │ │ │ ├── sorted-set.test.ts │ │ │ │ └── update-ttl.test.ts │ │ │ │ ├── http │ │ │ │ └── http-api.test.ts │ │ │ │ ├── leaderboard │ │ │ │ └── leaderboard.test.ts │ │ │ │ └── topics │ │ │ │ └── topic-client.test.ts │ │ └── unit │ │ │ ├── config │ │ │ └── transport │ │ │ │ └── transport-strategy.test.ts │ │ │ ├── internal │ │ │ └── auth-client.test.ts │ │ │ └── utils │ │ │ └── web-client-utils.test.ts │ └── tsconfig.json ├── common-integration-tests │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── auth │ │ │ └── auth-client.ts │ │ ├── cache │ │ │ ├── batch-get-set.ts │ │ │ ├── create-delete-list-cache.ts │ │ │ ├── dictionary.ts │ │ │ ├── get-set-delete.ts │ │ │ ├── item-get-ttl.ts │ │ │ ├── item-get-type.ts │ │ │ ├── keys-exist.ts │ │ │ ├── list.ts │ │ │ ├── replica-reads.ts │ │ │ ├── set.ts │ │ │ ├── sorted-set.ts │ │ │ └── update-ttl.ts │ │ ├── common-int-test-utils.ts │ │ ├── http │ │ │ └── http-apis.ts │ │ ├── index.ts │ │ ├── leaderboard │ │ │ └── leaderboard-client.ts │ │ ├── momento-jest-matchers.ts │ │ └── topics │ │ │ └── topic-client.ts │ ├── test │ │ └── unit │ │ │ └── placeholder.test.ts │ └── tsconfig.json └── core │ ├── .eslintignore │ ├── .eslintrc.json │ ├── .prettierrc.json │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── auth │ │ ├── credential-provider.ts │ │ ├── index.ts │ │ └── tokens │ │ │ ├── disposable-token-scope.ts │ │ │ ├── disposable-token-scopes.ts │ │ │ ├── permission-scope.ts │ │ │ └── permission-scopes.ts │ ├── clients │ │ ├── IAuthClient.ts │ │ ├── ICacheClient.ts │ │ ├── ILeaderboard.ts │ │ ├── ILeaderboardClient.ts │ │ ├── IMomentoCache.ts │ │ ├── IStorageClient.ts │ │ └── ITopicClient.ts │ ├── compression │ │ └── compression-level.ts │ ├── config │ │ ├── logging │ │ │ ├── index.ts │ │ │ ├── momento-logger.ts │ │ │ └── noop-momento-logger.ts │ │ └── read-concern.ts │ ├── errors │ │ ├── ICacheServiceErrorMapper.ts │ │ ├── errors.ts │ │ └── index.ts │ ├── index.ts │ ├── internal │ │ ├── clients │ │ │ ├── auth │ │ │ │ ├── AbstractAuthClient.ts │ │ │ │ └── index.ts │ │ │ ├── cache │ │ │ │ ├── AbstractCacheClient.ts │ │ │ │ ├── IControlClient.ts │ │ │ │ ├── IDataClient.ts │ │ │ │ ├── IPingClient.ts │ │ │ │ ├── index.ts │ │ │ │ └── momento-cache.ts │ │ │ ├── index.ts │ │ │ ├── leaderboard │ │ │ │ ├── AbstractLeaderboard.ts │ │ │ │ ├── ILeaderboardDataClient.ts │ │ │ │ └── index.ts │ │ │ ├── pubsub │ │ │ │ ├── AbstractPubsubClient.ts │ │ │ │ ├── AbstractTopicClient.ts │ │ │ │ ├── IPubsubClient.ts │ │ │ │ ├── IWebhookClient.ts │ │ │ │ └── index.ts │ │ │ └── storage │ │ │ │ ├── AbstractStorageClient.ts │ │ │ │ ├── IStorageControlClient.ts │ │ │ │ ├── IStorageDataClient.ts │ │ │ │ └── index.ts │ │ ├── subscription-state.ts │ │ └── utils │ │ │ ├── auth.ts │ │ │ ├── collections.ts │ │ │ ├── display.ts │ │ │ ├── index.ts │ │ │ ├── object.ts │ │ │ ├── semaphore.ts │ │ │ ├── sleep.ts │ │ │ ├── string.ts │ │ │ └── validators.ts │ ├── messages │ │ ├── cache-info.ts │ │ ├── responses │ │ │ ├── cache-batch-get.ts │ │ │ ├── cache-batch-set.ts │ │ │ ├── cache-delete.ts │ │ │ ├── cache-dictionary-fetch.ts │ │ │ ├── cache-dictionary-get-field.ts │ │ │ ├── cache-dictionary-get-fields.ts │ │ │ ├── cache-dictionary-increment.ts │ │ │ ├── cache-dictionary-length.ts │ │ │ ├── cache-dictionary-remove-field.ts │ │ │ ├── cache-dictionary-remove-fields.ts │ │ │ ├── cache-dictionary-set-field.ts │ │ │ ├── cache-dictionary-set-fields.ts │ │ │ ├── cache-flush.ts │ │ │ ├── cache-get.ts │ │ │ ├── cache-increment.ts │ │ │ ├── cache-item-get-ttl.ts │ │ │ ├── cache-item-get-type.ts │ │ │ ├── cache-key-exists.ts │ │ │ ├── cache-keys-exist.ts │ │ │ ├── cache-list-concatenate-back.ts │ │ │ ├── cache-list-concatenate-front.ts │ │ │ ├── cache-list-fetch.ts │ │ │ ├── cache-list-length.ts │ │ │ ├── cache-list-pop-back.ts │ │ │ ├── cache-list-pop-front.ts │ │ │ ├── cache-list-push-back.ts │ │ │ ├── cache-list-push-front.ts │ │ │ ├── cache-list-remove-value.ts │ │ │ ├── cache-list-retain.ts │ │ │ ├── cache-set-add-element.ts │ │ │ ├── cache-set-add-elements.ts │ │ │ ├── cache-set-contains-element.ts │ │ │ ├── cache-set-contains-elements.ts │ │ │ ├── cache-set-fetch.ts │ │ │ ├── cache-set-if-absent-or-equal.ts │ │ │ ├── cache-set-if-absent.ts │ │ │ ├── cache-set-if-equal.ts │ │ │ ├── cache-set-if-not-equal.ts │ │ │ ├── cache-set-if-not-exists.ts │ │ │ ├── cache-set-if-present-and-not-equal.ts │ │ │ ├── cache-set-if-present.ts │ │ │ ├── cache-set-length.ts │ │ │ ├── cache-set-pop.ts │ │ │ ├── cache-set-remove-element.ts │ │ │ ├── cache-set-remove-elements.ts │ │ │ ├── cache-set-sample.ts │ │ │ ├── cache-set.ts │ │ │ ├── cache-sorted-set-fetch.ts │ │ │ ├── cache-sorted-set-get-rank.ts │ │ │ ├── cache-sorted-set-get-score.ts │ │ │ ├── cache-sorted-set-get-scores.ts │ │ │ ├── cache-sorted-set-increment-score.ts │ │ │ ├── cache-sorted-set-length-by-score.ts │ │ │ ├── cache-sorted-set-length.ts │ │ │ ├── cache-sorted-set-put-element.ts │ │ │ ├── cache-sorted-set-put-elements.ts │ │ │ ├── cache-sorted-set-remove-element.ts │ │ │ ├── cache-sorted-set-remove-elements.ts │ │ │ ├── cache-ttl-decrease.ts │ │ │ ├── cache-ttl-increase.ts │ │ │ ├── cache-ttl-update.ts │ │ │ ├── create-cache.ts │ │ │ ├── delete-cache.ts │ │ │ ├── enums │ │ │ │ ├── auth │ │ │ │ │ ├── generate-api-key.ts │ │ │ │ │ ├── generate-disposable-token.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── refresh-api-key.ts │ │ │ │ ├── cache │ │ │ │ │ ├── control │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── dictionary │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── list │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── scalar │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── set │ │ │ │ │ │ └── index.ts │ │ │ │ │ └── sorted-set │ │ │ │ │ │ └── index.ts │ │ │ │ ├── index.ts │ │ │ │ ├── leaderboard │ │ │ │ │ └── index.ts │ │ │ │ ├── store │ │ │ │ │ ├── control │ │ │ │ │ │ └── index.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── scalar │ │ │ │ │ │ └── index.ts │ │ │ │ ├── topics │ │ │ │ │ └── index.ts │ │ │ │ └── webhook │ │ │ │ │ └── index.ts │ │ │ ├── generate-api-key.ts │ │ │ ├── generate-disposable-token.ts │ │ │ ├── grpc-response-types.ts │ │ │ ├── leaderboard │ │ │ │ ├── index.ts │ │ │ │ ├── leaderboard-delete.ts │ │ │ │ ├── leaderboard-fetch.ts │ │ │ │ ├── leaderboard-length.ts │ │ │ │ ├── leaderboard-remove-elements.ts │ │ │ │ └── leaderboard-upsert.ts │ │ │ ├── list-caches.ts │ │ │ ├── refresh-api-key.ts │ │ │ ├── response-base.ts │ │ │ ├── storage │ │ │ │ ├── control │ │ │ │ │ ├── create-store.ts │ │ │ │ │ ├── delete-store.ts │ │ │ │ │ ├── index.ts │ │ │ │ │ └── list-stores.ts │ │ │ │ ├── index.ts │ │ │ │ └── scalar │ │ │ │ │ ├── index.ts │ │ │ │ │ ├── storage-delete.ts │ │ │ │ │ ├── storage-get.ts │ │ │ │ │ ├── storage-put.ts │ │ │ │ │ └── storage-value.ts │ │ │ ├── topic-discontinuity.ts │ │ │ ├── topic-heartbeat.ts │ │ │ ├── topic-item.ts │ │ │ ├── topic-publish.ts │ │ │ ├── topic-subscribe.ts │ │ │ └── webhook │ │ │ │ ├── delete-webhook.ts │ │ │ │ ├── get-webhook-secret.ts │ │ │ │ ├── index.ts │ │ │ │ ├── list-webhooks.ts │ │ │ │ ├── put-webhook.ts │ │ │ │ └── rotate-webhook-secret.ts │ │ ├── signing-key.ts │ │ ├── store-info.ts │ │ └── webhook.ts │ └── utils │ │ ├── cache-call-options.ts │ │ ├── collection-ttl.ts │ │ ├── expiration.ts │ │ ├── index.ts │ │ ├── itemType.ts │ │ ├── set-batch-item.ts │ │ ├── time.ts │ │ ├── topic-call-options.ts │ │ ├── webhook-call-options.ts │ │ └── webhook-destination.ts │ ├── test │ └── unit │ │ ├── auth │ │ ├── credential-provider.test.ts │ │ ├── disposable-token-scope.test.ts │ │ └── permission-scope.test.ts │ │ ├── cache-get.test.ts │ │ ├── cache-list-fetch.test.ts │ │ ├── cache-list-push-front.test.ts │ │ ├── cache-set-fetch.test.ts │ │ ├── clients │ │ └── imomentocache-interface.test.ts │ │ ├── messages │ │ └── get-response.test.ts │ │ └── utils │ │ ├── auth.test.ts │ │ ├── collection-ttl.test.ts │ │ ├── display.test.ts │ │ ├── expiration.test.ts │ │ └── semaphore.test.ts │ └── tsconfig.json └── scripts ├── build-all-examples.sh ├── build-all-packages.sh ├── build-and-test-all-packages-consistent-reads.sh ├── build-and-test-all-packages.sh ├── build-and-test-package-consistent-reads.sh ├── build-and-test-package-retry-tests.sh ├── build-and-test-package.sh ├── build-nodejs-sdk-for-lambda.sh ├── build-nodejs-sdk.sh ├── build-package-lambda.sh ├── build-package.sh ├── build-web-sdk.sh ├── make-localhost-token-from-dev-token.sh ├── publish-all-packages.sh ├── publish-package.sh ├── test-auth-packages.sh ├── test-leaderboard-packages.sh ├── test-store-packages.sh ├── update-all-examples-dependencies.sh ├── update-package-versions.sh └── wait-for-npmjs-release.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | # These are encrypted files. Don't mess with them. 12 | [*.enc] 13 | trim_trailing_whitespace = false 14 | insert_final_newline = false 15 | -------------------------------------------------------------------------------- /.github/workflows/manual-release.yml: -------------------------------------------------------------------------------- 1 | name: Manual Release 2 | # Triggers a merge from main->release, which will then trigger a release 3 | # from the release branch. 4 | on: 5 | # Allows you to run this workflow manually from the Actions tab 6 | workflow_dispatch: 7 | 8 | jobs: 9 | merge-to-release-branch: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Merge main -> release 15 | uses: devmasx/merge-branch@master 16 | with: 17 | type: now 18 | from_branch: main 19 | target_branch: release 20 | github_token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .DS_Store 4 | .idea 5 | .node-version 6 | *.tgz 7 | !.vscode/*code-workspace 8 | .env 9 | -------------------------------------------------------------------------------- /.vscode/client-sdk-javascript.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "..", 5 | "name": "", 6 | }, 7 | { 8 | "path": "../packages/core", 9 | "name": "packages/core", 10 | }, 11 | { 12 | "path": "../packages/client-sdk-nodejs", 13 | "name": "packages/client-sdk-nodejs", 14 | }, 15 | { 16 | "path": "../packages/client-sdk-nodejs-compression", 17 | "name": "packages/client-sdk-nodejs-compression", 18 | }, 19 | { 20 | "path": "../packages/client-sdk-web", 21 | "name": "packages/client-sdk-web", 22 | }, 23 | { 24 | "path": "../packages/common-integration-tests", 25 | "name": "packages/common-integration-tests", 26 | }, 27 | { 28 | "path": "../examples/nodejs/aws/lambda-examples/advanced-compression", 29 | "name": "examples/nodejs/aws/lambda-examples/advanced-compression", 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /examples/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento JavaScript SDK Examples 4 | 5 | Working example projects, with all required build configuration files, are available for the node.js and web SDKs, as well 6 | as various other environments: 7 | 8 | * [Node.js SDK examples (including AWS Lambda)](./nodejs) 9 | * [Web SDK examples](./web) 10 | * [CloudFlare examples](./cloudflare) 11 | * [Deno examples](./deno) 12 | * [Fast.ly examples](./fastly) 13 | 14 | {{ ossFooter }} 15 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/http-api/.dev.vars: -------------------------------------------------------------------------------- 1 | MOMENTO_API_KEY="" 2 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/http-api/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/http-api/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/http-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shy-bush-898e", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "deploy": "wrangler deploy", 7 | "start": "wrangler dev", 8 | "build": "tsc" 9 | }, 10 | "devDependencies": { 11 | "@cloudflare/workers-types": "^4.20230419.0", 12 | "typescript": "^5.0.4", 13 | "wrangler": "^3.0.0" 14 | }, 15 | "dependencies": { } 16 | } 17 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/http-api/wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "momento-cloudflare-worker-http" 2 | main = "src/worker.ts" 3 | compatibility_date = "2023-07-10" 4 | keep_vars = true 5 | 6 | # [vars] 7 | # MOMENTO_HTTP_ENDPOINT = "REPLACE ME" 8 | # MOMENTO_CACHE_NAME = "REPLACE ME" 9 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/web-sdk/.dev.vars: -------------------------------------------------------------------------------- 1 | #MOMENTO_API_KEY="" 2 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/web-sdk/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/web-sdk/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/web-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shy-bush-898e", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "deploy": "wrangler deploy", 7 | "start": "wrangler dev", 8 | "build": "tsc" 9 | }, 10 | "devDependencies": { 11 | "@cloudflare/workers-types": "^4.20230419.0", 12 | "typescript": "^5.0.4", 13 | "wrangler": "^3.0.0" 14 | }, 15 | "dependencies": { 16 | "@gomomento/sdk-core": "^1.40.0", 17 | "@gomomento/sdk-web": "^1.111.0", 18 | "xhr4sw": "^0.0.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/web-sdk/wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "momento-cloudflare-worker-web" 2 | main = "src/worker.ts" 3 | compatibility_date = "2023-07-10" 4 | keep_vars = true 5 | 6 | # [vars] 7 | # MOMENTO_CACHE_NAME = "REPLACE ME" 8 | -------------------------------------------------------------------------------- /examples/deno/http-api/.env.example: -------------------------------------------------------------------------------- 1 | MOMENTO_API_KEY="" 2 | MOMENTO_CACHE_NAME="" 3 | MOMENTO_HTTP_ENDPOINT="" 4 | -------------------------------------------------------------------------------- /examples/deno/http-api/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | node_modules -------------------------------------------------------------------------------- /examples/deno/http-api/deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "lib": ["deno.window"], 5 | "strict": true 6 | }, 7 | "lint": { 8 | "include": ["*.ts"], 9 | "exclude": [] 10 | }, 11 | "fmt": { 12 | "useTabs": true, 13 | "lineWidth": 80, 14 | "indentWidth": 4, 15 | "semiColons": false, 16 | "singleQuote": true, 17 | "proseWrap": "preserve", 18 | "include": ["*.ts"] 19 | }, 20 | "lock": false, 21 | "nodeModulesDir": true, 22 | "tasks": { 23 | "start": "deno run --allow-read --allow-env --allow-net index.ts" 24 | }, 25 | "imports": { 26 | "http": "https://deno.land/std@0.198.0/http/server.ts", 27 | "dotenv": "https://deno.land/std/dotenv/mod.ts", 28 | "momento_http": "https://deno.land/x/momento_http@v0.2.0/src/index.ts" 29 | } 30 | } -------------------------------------------------------------------------------- /examples/deno/web-sdk/.env.example: -------------------------------------------------------------------------------- 1 | MOMENTO_API_KEY="" 2 | MOMENTO_CACHE_NAME="" 3 | -------------------------------------------------------------------------------- /examples/deno/web-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | node_modules -------------------------------------------------------------------------------- /examples/deno/web-sdk/deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "lib": ["deno.window"], 5 | "strict": true 6 | }, 7 | "lint": { 8 | "include": ["*.ts"], 9 | "exclude": [] 10 | }, 11 | "fmt": { 12 | "useTabs": true, 13 | "lineWidth": 80, 14 | "indentWidth": 4, 15 | "semiColons": false, 16 | "singleQuote": true, 17 | "proseWrap": "preserve", 18 | "include": ["*.ts"] 19 | }, 20 | "lock": false, 21 | "nodeModulesDir": true, 22 | "tasks": { 23 | "start": "deno run --allow-read --allow-env --allow-net index.ts" 24 | }, 25 | "imports": { 26 | "http": "https://deno.land/std@0.198.0/http/server.ts", 27 | "momento": "npm:@gomomento/sdk-web@1.93.0", 28 | "xhr4sw": "npm:xhr4sw@0.0.5", 29 | "dotenv": "https://deno.land/std/dotenv/mod.ts" 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/fastly-compute/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/fastly-compute/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /bin 3 | /build 4 | /pkg 5 | secrets.json -------------------------------------------------------------------------------- /examples/fastly-compute/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/fastly-compute/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/fastly-compute/secrets.json.example: -------------------------------------------------------------------------------- 1 | { 2 | "MOMENTO_HTTP_ENDPOINT": "api.cache.cell-4-us-west-2-1.prod.a.momentohq.com", 3 | "MOMENTO_BACKEND": "aws_us_west_2_http", 4 | "MOMENTO_CACHE": "", 5 | "MOMENTO_API_KEY": "" 6 | } 7 | -------------------------------------------------------------------------------- /examples/fastly-compute/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "module": "ES2022", 5 | "target": "ES2022", 6 | "moduleResolution": "node", 7 | "esModuleInterop": true, 8 | "lib": ["ES2022"], 9 | "rootDir": "src", 10 | "outDir": "build", 11 | "resolveJsonModule": true, 12 | "allowJs": true, 13 | "checkJs": false, 14 | "isolatedModules": true, 15 | "allowSyntheticDefaultImports": true, 16 | "forceConsistentCasingInFileNames": true, 17 | "skipLibCheck": true, 18 | // requires the `override` keyword to override a method/property from a parent class 19 | "noImplicitOverride": true, 20 | "noFallthroughCasesInSwitch": true 21 | }, 22 | "include": [ 23 | "./src/**/*.js", 24 | "./src/**/*.ts", 25 | ], 26 | "exclude": [ 27 | "node_modules" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/access-control/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/access-control/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/access-control/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/access-control/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento Node.js SDK - Access Control Examples 4 | 5 | ## Example Requirements 6 | 7 | - Node version 16 or higher is required 8 | - A Momento API key is required, you can generate one using the [Momento Console](https://console.gomomento.com) 9 | 10 | To run any of the examples you will need to install the dependencies once first: 11 | 12 | ```bash 13 | npm install 14 | ``` 15 | 16 | ## Running the Example 17 | 18 | This example demonstrates creating and using Momento API keys with different permissions 19 | 20 | ```bash 21 | # Run example code 22 | MOMENTO_API_KEY= npm run access-control 23 | ``` 24 | 25 | Example Code: [access-control.ts](access-control.ts) 26 | 27 | If you have questions or need help experimenting further, please reach out to us! 28 | 29 | {{ ossFooter }} 30 | -------------------------------------------------------------------------------- /examples/nodejs/access-control/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/.gitignore: -------------------------------------------------------------------------------- 1 | ./node_modules 2 | .env 3 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento Javascript NodeJS SDK - Momento <-> Eventbridge Project Example - TypeScript CLI App 4 | 5 | ## About 6 | 7 | The parent directory contains a project demonstrating a write-through cache pattern for DynamoDB using DynamoDB Streams, AWS EventBridge and Momento. 8 | 9 | This directory contains a TypeScript CLI app that illustrates how to use the Momento NodeJS SDK to interact with the 10 | Momento EventBridge integration. The code subscribes to a Momento Topic, writes to DynamoDB, and then illustrates that 11 | the DDB updates are propagated to Momento Topics and Cache via DynamoDB Streams and EventBridge. 12 | 13 | This CLI app relies on configuration and infrastructure defined in the parent directory. Check out [the README in the parent directory](../README.md) for complete instructions. 14 | 15 | {{ ossFooter }} 16 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/cliApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/bin/eventbridge.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import 'source-map-support/register'; 3 | import * as cdk from 'aws-cdk-lib'; 4 | import { EventbridgeStack } from '../lib/eventbridge-stack'; 5 | 6 | const app = new cdk.App(); 7 | new EventbridgeStack(app, 'momento-ddb-eventbridge-stack', {}); 8 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "0.1.0", 4 | "bin": { 5 | "test": "infrastructure/bin/test.js" 6 | }, 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest", 11 | "cdk": "cdk", 12 | "deploy": "cd ../infrastructure && npm install && cd - && cdk deploy" 13 | }, 14 | "devDependencies": { 15 | "@types/jest": "^29.5.12", 16 | "@types/node": "20.12.7", 17 | "jest": "^29.7.0", 18 | "ts-jest": "^29.1.2", 19 | "aws-cdk": "2.140.0", 20 | "ts-node": "^10.9.2", 21 | "typescript": "~5.4.5" 22 | }, 23 | "dependencies": { 24 | "aws-cdk-lib": "2.140.0", 25 | "constructs": "^10.0.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/momento-eventbridge.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/aws/eventbridge/momento-eventbridge.drawio.png -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/subscribe-to-topic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | 5 | # Set Momento Cache and Topic Name 6 | CACHE_NAME="momento-eventbridge-cache" 7 | TOPIC_NAME="momento-eventbridge-topic" 8 | 9 | # Subscribe to topic 10 | echo "Subscribing to topic..." 11 | momento topic subscribe $TOPIC_NAME --cache $CACHE_NAME 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { browser: true, es2020: true }, 3 | extends: [ 4 | 'eslint:recommended', 5 | 'plugin:@typescript-eslint/recommended', 6 | 'plugin:react-hooks/recommended', 7 | ], 8 | parser: '@typescript-eslint/parser', 9 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 10 | plugins: ['react-refresh'], 11 | rules: { 12 | 'react-refresh/only-export-components': 'warn', 13 | }, 14 | } 15 | 16 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | 26 | .env.* 27 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "printWidth": 80, 4 | "singleQuote": false, 5 | "jsxSingleQuote": false, 6 | "semi": true, 7 | "trailingComma": "all", 8 | "tabWidth": 2 9 | } 10 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento Javascript NodeJS SDK - Momento <-> Eventbridge Project Example - Web App 4 | 5 | ## About 6 | 7 | The parent directory contains a project demonstrating a write-through cache pattern for DynamoDB using DynamoDB Streams, AWS EventBridge and Momento. 8 | 9 | This directory contains a browser app that illustrates how to use the Momento Web SDK to interact with the 10 | Momento EventBridge integration. The app subscribes to a Momento Topic, provides a form to submit writes to DynamoDB, and then illustrates that 11 | the DDB updates are propagated to Momento Topics and Cache via DynamoDB Streams and EventBridge. 12 | 13 | This web app relies on configuration and infrastructure defined in the parent directory. Check out [the README in the parent directory](../README.md) for complete instructions. 14 | 15 | {{ ossFooter }} 16 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Momento Eventbridge Demo 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/aws/eventbridge/webapp/public/favicon.ico -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | margin: 0 auto; 3 | padding: 1rem; 4 | text-align: center; 5 | } 6 | 7 | .logo { 8 | height: 6em; 9 | padding: 1.5em; 10 | will-change: filter; 11 | transition: filter 300ms; 12 | } 13 | .logo:hover { 14 | filter: drop-shadow(0 0 2em #646cffaa); 15 | } 16 | .logo.react:hover { 17 | filter: drop-shadow(0 0 2em #61dafbaa); 18 | } 19 | 20 | @keyframes logo-spin { 21 | from { 22 | transform: rotate(0deg); 23 | } 24 | to { 25 | transform: rotate(360deg); 26 | } 27 | } 28 | 29 | @media (prefers-reduced-motion: no-preference) { 30 | a:nth-of-type(2) .logo { 31 | animation: logo-spin infinite 20s linear; 32 | } 33 | } 34 | 35 | .card { 36 | padding: 2em; 37 | } 38 | 39 | .read-the-docs { 40 | color: #888; 41 | } 42 | 43 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/main.tsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom/client"; 2 | import App from "./App"; 3 | import "./index.css"; 4 | import {ToastContainer} from "react-toastify"; 5 | 6 | // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 7 | ReactDOM.createRoot(document.getElementById("root")!).render( 8 | <> 9 | 10 | 11 | 12 | ); 13 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/arrow-down.tsx: -------------------------------------------------------------------------------- 1 | export const ArrowDown = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/arrow-left.tsx: -------------------------------------------------------------------------------- 1 | export const ArrowLeft = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/arrow-right.tsx: -------------------------------------------------------------------------------- 1 | export const ArrowRight = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | 9 | 10 | ); 11 | }; 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/ban-circle.tsx: -------------------------------------------------------------------------------- 1 | export const BanCircle = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | 9 | ); 10 | }; 11 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/check-circle.tsx: -------------------------------------------------------------------------------- 1 | export const CheckCircle = () => { 2 | return ( 3 | 4 | 6 | 7 | ); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/corner-left-down.tsx: -------------------------------------------------------------------------------- 1 | export const CornerLeftDown = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/corner-right-down.tsx: -------------------------------------------------------------------------------- 1 | export const CornerRightDown = () => { 2 | return ( 3 | 5 | 6 | 7 | 8 | ); 9 | }; 10 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/svgs/help.tsx: -------------------------------------------------------------------------------- 1 | export const Help = () => { 2 | return ( 3 | 10 | 16 | 17 | ); 18 | }; 19 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/utils/toast.tsx: -------------------------------------------------------------------------------- 1 | import { toast } from "react-toastify"; 2 | 3 | const defaultToastOptions = { 4 | hideProgressBar: true, 5 | position: "top-center", 6 | autoClose: 2000, 7 | } as const; 8 | 9 | const toastSuccess = (message: string) => { 10 | toast(message, { 11 | ...defaultToastOptions, 12 | type: "success", 13 | }); 14 | }; 15 | 16 | const toastError = (message: string) => { 17 | toast(message, { 18 | ...defaultToastOptions, 19 | type: "error", 20 | }); 21 | }; 22 | 23 | const toastInfo = (message: string) => { 24 | toast(message, { 25 | ...defaultToastOptions, 26 | type: "info", 27 | }); 28 | }; 29 | 30 | export { toastSuccess, toastError, toastInfo }; 31 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | interface ImportMetaEnv { 4 | readonly VITE_AWS_ACCESS_KEY_ID: string; 5 | readonly VITE_AWS_SECRET_ACCESS_KEY: string; 6 | readonly VITE_AWS_SESSION_TOKEN: string; 7 | readonly VITE_MOMENTO_API_KEY: string; 8 | readonly VITE_AWS_REGION: string; 9 | } 10 | 11 | interface ImportMeta { 12 | readonly env: ImportMetaEnv; 13 | } 14 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/store/controlplane-store.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/aws/eventbridge/webapp/store/controlplane-store.ts -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], 4 | theme: { 5 | extend: { 6 | colors: { 7 | teal: { 8 | 500: '#00C88C' 9 | }, 10 | }, 11 | }, 12 | }, 13 | plugins: [], 14 | } 15 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | "moduleResolution": "node", 9 | "allowImportingTsExtensions": true, 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "noEmit": true, 13 | "jsx": "react-jsx", 14 | "strict": true, 15 | "noUnusedLocals": true, 16 | "noUnusedParameters": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "allowSyntheticDefaultImports": true, 19 | "allowJs": true, 20 | }, 21 | "include": ["src", "vite.config.ts"], 22 | "exclude": ["infrastructure"], 23 | "references": [{ "path": "./tsconfig.node.json" }] 24 | } 25 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "strict": true 9 | }, 10 | "include": ["vite.config.ts"], 11 | "exclude": ["infrastructure"] 12 | } 13 | -------------------------------------------------------------------------------- /examples/nodejs/aws/eventbridge/webapp/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import react from "@vitejs/plugin-react-swc"; 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | define: { 8 | "process.env": process.env, 9 | global: "window", 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento Node.js SDK - AWS Lambda Examples 4 | 5 | Working example projects, with all required build configuration files, for using the Momento Node.js SDK in AWS Lambda functions. 6 | 7 | * [Simple cache get](./simple-get) - a very basic lambda that just illustrates how to initialize a cache client and do some basic reads 8 | * [Cloudwatch metrics](./cloudwatch-metrics) - a lambda that demonstrates how to use metrics middleware to generate CloudWatch metrics for cache operations that occur in your lambda, including an example CloudWatch dashboard! 9 | * [Advanced compression](./advanced-compression) - a lambda that demonstrates how to package the `@gomomento/sdk-nodejs-compression-zstd` dependency in your lambda, if you have an advanced compression use case that requires the `zstd` extension rather than the default `@gomomento/sdk-nodejs-compression` extension. 10 | 11 | {{ ossFooter }} 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | *.d.ts 3 | node_modules 4 | 5 | # CDK asset staging directory 6 | .cdk.staging 7 | cdk.out 8 | 9 | src/lambda/dist 10 | src/lambda/node_modules 11 | 12 | src/zstd-layer/nodejs/node_modules 13 | src/zstd-layer/*.zip 14 | 15 | infrastructure/cdk.out 16 | infrastructure/.cdk.staging 17 | infrastructure/node_modules 18 | infrastructure/result.json 19 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/infrastructure/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/infrastructure/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/infrastructure/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/infrastructure/bin/advanced-compression-cdk.ts: -------------------------------------------------------------------------------- 1 | import 'source-map-support/register'; 2 | import * as cdk from 'aws-cdk-lib'; 3 | import {AdvancedCompressionCdkStack} from '../lib/advanced-compression-cdk-stack'; 4 | 5 | const app = new cdk.App(); 6 | const momentoApiKey = process.env.MOMENTO_API_KEY; 7 | 8 | if (!momentoApiKey) { 9 | throw new Error('MOMENTO_API_KEY environment variable is required'); 10 | } 11 | 12 | new AdvancedCompressionCdkStack(app, 'AdvancedCompressionCdkStack', { 13 | env: { 14 | momentoApiKey: momentoApiKey, 15 | }, 16 | }); 17 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2020", 7 | "dom" 8 | ], 9 | "declaration": true, 10 | "strict": true, 11 | "noImplicitAny": true, 12 | "strictNullChecks": true, 13 | "noImplicitThis": true, 14 | "alwaysStrict": true, 15 | "noUnusedLocals": false, 16 | "noUnusedParameters": false, 17 | "noImplicitReturns": true, 18 | "noFallthroughCasesInSwitch": false, 19 | "inlineSourceMap": true, 20 | "inlineSources": true, 21 | "experimentalDecorators": true, 22 | "strictPropertyInitialization": false, 23 | "typeRoots": [ 24 | "./node_modules/@types" 25 | ] 26 | }, 27 | "exclude": [ 28 | "node_modules", 29 | "cdk.out" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/lambda/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/lambda/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/lambda/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/lambda/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "lib": ["es2020"], 7 | "strict": true, 8 | "noImplicitAny": true, 9 | "strictNullChecks": true, 10 | "noImplicitThis": true, 11 | "alwaysStrict": true, 12 | "noUnusedLocals": false, 13 | "noUnusedParameters": false, 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": false, 16 | "inlineSourceMap": true, 17 | "inlineSources": true, 18 | "strictPropertyInitialization": false 19 | }, 20 | "exclude": ["node_modules"] 21 | } 22 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/zstd-layer/nodejs/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression-cdk/src/zstd-layer/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "npm install --platform=linux --arch=x64 && cd .. && zip -r zstd_x64_layer.zip nodejs" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@gomomento/sdk": "^1.111.0", 14 | "@gomomento/sdk-nodejs-compression-zstd": "^0.111.0", 15 | "@mongodb-js/zstd": "^2.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/.gitignore: -------------------------------------------------------------------------------- 1 | function.zip 2 | .aws-sam 3 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM amazonlinux:2023 2 | 3 | # Install build dependencies 4 | RUN yum install -y zip && \ 5 | curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \ 6 | yum install -y nodejs && \ 7 | npm install -g node-gyp 8 | 9 | WORKDIR /app 10 | 11 | COPY package.json package-lock.json tsconfig.json esbuild.ts postbuild.ts ./ 12 | COPY src ./src 13 | 14 | RUN npm install --platform=linux --arch=x64 15 | RUN npm run build 16 | 17 | CMD ["cp", "function.zip", "/output/"] 18 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": ".ts,.js", 4 | "ignore": [], 5 | "exec": "npx ts-node ./src/index.ts" 6 | } 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@types/aws-lambda": "^8.10.110", 4 | "@types/node": "^18.13.0", 5 | "nodemon": "^2.0.20", 6 | "serverless": "^3.38.0", 7 | "serverless-better-credentials": "^2.0.0", 8 | "ts-node": "^10.9.1", 9 | "typescript": "^4.9.5" 10 | }, 11 | "dependencies": { 12 | "@gomomento/sdk": "^1.111.0", 13 | "@gomomento/sdk-nodejs-compression-zstd": "^0.111.0", 14 | "aws-lambda": "^1.0.7", 15 | "esbuild": "^0.20.2" 16 | }, 17 | "scripts": { 18 | "prebuild": "rm -rf dist", 19 | "build": "ts-node esbuild.ts", 20 | "build:aws": "docker build -t lambda-builder . && docker run --rm -v \"$(pwd):/output\" lambda-builder", 21 | "postbuild": "ts-node postbuild.ts" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/postbuild.ts: -------------------------------------------------------------------------------- 1 | import {execSync} from 'child_process'; 2 | import * as fs from "node:fs"; 3 | 4 | const functionsDir = 'src'; 5 | const commands = [ 6 | 'ls -lah', 7 | `cd dist/`, 8 | `echo "zipping ${functionsDir} lambda"`, 9 | `zip -R function.zip *`, 10 | `mv function.zip ../`, 11 | 'cd ..', 12 | ]; 13 | 14 | execSync(commands.join(' && '), { 15 | stdio: 'inherit', 16 | }); 17 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/advanced-compression/template.yaml: -------------------------------------------------------------------------------- 1 | Transform: AWS::Serverless-2016-10-31 2 | Parameters: 3 | MomentoApiKey: 4 | Type: String 5 | Description: API key for Momento 6 | Resources: 7 | ExampleFunction: 8 | Type: AWS::Serverless::Function 9 | Properties: 10 | CodeUri: function.zip 11 | Handler: index.handler 12 | Runtime: nodejs20.x 13 | Timeout: 30 14 | Architectures: 15 | - x86_64 16 | Events: 17 | HelloWorld: 18 | Type: Api 19 | Properties: 20 | Path: /hello 21 | Method: get 22 | Environment: 23 | Variables: 24 | NODE_OPTIONS: --enable-source-maps 25 | MOMENTO_API_KEY: !Ref MomentoApiKey 26 | Metadata: 27 | SkipBuild: True 28 | 29 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM --platform=linux/amd64 public.ecr.aws/docker/library/node:18 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY ecs-code/index.ts ./ 6 | COPY ecs-code/package.json ./ 7 | RUN npm install 8 | 9 | ENV MOMENTO_API_KEY_SECRET_NAME="MomentoMetricsApiKey" 10 | CMD ["npm", "run", "start"] 11 | 12 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/ecs-code/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/ecs-code/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/ecs-code/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/ecs-code/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/docker/ecs-code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", "dom" 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | .env 6 | 7 | # CDK asset staging directory 8 | .cdk.staging 9 | cdk.out 10 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/cloudwatch-metrics/lambda/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/lambda-examples/simple-get/lambda/simple-get/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "devDependencies": { 8 | "typescript": "^5.4.5" 9 | } 10 | }, 11 | "node_modules/typescript": { 12 | "version": "5.4.5", 13 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", 14 | "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", 15 | "dev": true, 16 | "bin": { 17 | "tsc": "bin/tsc", 18 | "tsserver": "bin/tsserver" 19 | }, 20 | "engines": { 21 | "node": ">=14.17" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/aws/secrets-manager/.gitignore -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento Node.js SDK - AWS Secrets Manager Example 4 | 5 | This example demonstrates how to retrieve a Momento API key stored as a secret in AWS Secrets Manager and use it to create a cache. 6 | 7 | ## Example Requirements 8 | 9 | - Node version 16 or higher is required 10 | - To get started with Momento you will need a Momento API key. You can get one from the [Momento Console](https://console.gomomento.com). 11 | 12 | To run any of the examples you will need to install the dependencies once first: 13 | 14 | ```bash 15 | npm install 16 | ``` 17 | 18 | ## Running the AWS Secrets Manager Example 19 | 20 | ```bash 21 | # Run example code 22 | MOMENTO_API_KEY= npm run secrets-example 23 | ``` 24 | 25 | [Example Code](doc-example-files/doc-examples-js-aws-secrets.ts) 26 | 27 | If you have questions or need help experimenting further, please reach out to us! 28 | 29 | {{ ossFooter }} 30 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/doc-example-files/README.md: -------------------------------------------------------------------------------- 1 | This directory contains files that will be pulled in to the docs site for use in code examples. 2 | Use caution when modifying any files in this directory! 3 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/aws/secrets-manager/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/cache/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/cache/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/cache/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/cache/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /examples/nodejs/cache/doc-example-files/README.md: -------------------------------------------------------------------------------- 1 | This directory contains files that will be pulled in to the docs site for use in code examples. 2 | Use caution when modifying any files in this directory! 3 | -------------------------------------------------------------------------------- /examples/nodejs/cache/doc-example-files/cheat-sheet-main.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import {CacheClient} from '@gomomento/sdk'; 3 | 4 | async function main() { 5 | const cacheClient = await CacheClient.create({ 6 | defaultTtlSeconds: 60, 7 | }); 8 | } 9 | 10 | main().catch(e => { 11 | console.error(`Uncaught exception while running example: ${JSON.stringify(e)}`); 12 | throw e; 13 | }); 14 | -------------------------------------------------------------------------------- /examples/nodejs/cache/doc-example-files/collection-ttl.ts: -------------------------------------------------------------------------------- 1 | import {CollectionTtl} from '@gomomento/sdk'; 2 | 3 | function example_API_CollectionTtlOf() { 4 | CollectionTtl.of(20 * 60); // 20 minutes 5 | } 6 | 7 | function example_API_CollectionTtlNew() { 8 | const ttlSeconds = 20 * 60; // 20 minutes 9 | const refreshTtl = true; 10 | new CollectionTtl(ttlSeconds, refreshTtl); 11 | } 12 | 13 | function example_API_CollectionTtlOfNoRefresh() { 14 | CollectionTtl.of(20 * 60).withNoRefreshTtlOnUpdates(); // 20 minutes, only when collection is created 15 | } 16 | 17 | function example_API_CollectionTtlNewNoRefresh() { 18 | const ttlSeconds = 20 * 60; // 20 minutes 19 | const refreshTtl = false; 20 | new CollectionTtl(ttlSeconds, refreshTtl); 21 | } 22 | 23 | function main() { 24 | example_API_CollectionTtlOf(); 25 | example_API_CollectionTtlNew(); 26 | example_API_CollectionTtlOfNoRefresh(); 27 | example_API_CollectionTtlNewNoRefresh(); 28 | } 29 | 30 | main(); 31 | -------------------------------------------------------------------------------- /examples/nodejs/cache/doc-example-files/myfile.json: -------------------------------------------------------------------------------- 1 | {"foo": 42} 2 | -------------------------------------------------------------------------------- /examples/nodejs/cache/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/cache/readme.ts: -------------------------------------------------------------------------------- 1 | import {CacheClient, CacheGetResponse} from '@gomomento/sdk'; 2 | 3 | async function main() { 4 | const cacheClient = await CacheClient.create({ 5 | defaultTtlSeconds: 60, 6 | }); 7 | 8 | await cacheClient.createCache('cache'); 9 | await cacheClient.set('cache', 'foo', 'FOO'); 10 | const getResponse = await cacheClient.get('cache', 'foo'); 11 | if (getResponse.type === CacheGetResponse.Hit) { 12 | console.log(`Got value: ${getResponse.valueString()}`); 13 | } 14 | } 15 | 16 | main().catch(e => { 17 | throw e; 18 | }); 19 | -------------------------------------------------------------------------------- /examples/nodejs/cache/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/cache/utils/collections.ts: -------------------------------------------------------------------------------- 1 | export function range(n: number): Array { 2 | return [...Array(n).keys()]; 3 | } 4 | -------------------------------------------------------------------------------- /examples/nodejs/cache/utils/time.ts: -------------------------------------------------------------------------------- 1 | export function delay(ms: number) { 2 | return new Promise(resolve => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/compression-zstd/.gitignore -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/compression-zstd/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/compression/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/compression/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/compression/.gitignore -------------------------------------------------------------------------------- /examples/nodejs/compression/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/compression/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /examples/nodejs/compression/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/compression/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/get-set-batch-perf-test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/load-gen/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/utils/collections.ts: -------------------------------------------------------------------------------- 1 | export function range(n: number): Array { 2 | return [...Array(n).keys()]; 3 | } 4 | -------------------------------------------------------------------------------- /examples/nodejs/load-gen/utils/time.ts: -------------------------------------------------------------------------------- 1 | export function delay(ms: number) { 2 | return new Promise(resolve => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /examples/nodejs/mongodb-examples/simple-read-aside/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | -------------------------------------------------------------------------------- /examples/nodejs/mongodb-examples/simple-read-aside/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 30000, 12 | }; 13 | 14 | export default config; 15 | -------------------------------------------------------------------------------- /examples/nodejs/mongodb-examples/simple-read-aside/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example-momento-mongodb-read-aside", 3 | "version": "0.1.0", 4 | "author": "NoSQLKnowHow", 5 | "description": "A quick example of using Momento Cache as a read-aside cache with MongoDB.", 6 | "license": "Apache 2.0", 7 | "scripts": { 8 | "build": "tsc", 9 | "watch": "tsc -w", 10 | "test": "jest" 11 | }, 12 | "dependencies": { 13 | "@aws-sdk/client-secrets-manager": "^3.369.0", 14 | "@gomomento/sdk": "^1.111.0", 15 | "mongodb": "^5.8.0" 16 | }, 17 | "devDependencies": { 18 | "@types/jest": "^29.5.1", 19 | "@types/node": "^20.3.2", 20 | "eslint": "^8.19.0", 21 | "eslint-config-prettier": "^8.5.0", 22 | "eslint-plugin-import": "^2.26.0", 23 | "eslint-plugin-node": "^11.1.0", 24 | "eslint-plugin-prettier": "^4.2.1", 25 | "jest": "^29", 26 | "jest-extended": "^3.2.3", 27 | "prettier": "^2.7.1", 28 | "ts-jest": "^29", 29 | "ts-node": "^10.9.1", 30 | "typescript": "~5.1.3" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /examples/nodejs/mongodb-examples/simple-read-aside/test/wrapper.test.ts: -------------------------------------------------------------------------------- 1 | import CreateCacheClient from "../src/lib/getClientFunctions"; 2 | import {ReadAsideWrapper} from "../src/read-aside-momento-mongo"; 3 | 4 | describe('WrapperTests', () => { 5 | it('can construct a read aside wrapper and execute a function', async () => { 6 | let client = await CreateCacheClient(10800); // default to 3 hours 7 | // init the read-aside class in read-aside-momento-mongo.ts 8 | const wrapper = new ReadAsideWrapper({ 9 | client: client, 10 | cacheName: "movies" 11 | }); 12 | // Call the getItem function in the read-aside class and pass in the key and loader function with test return value 13 | const ret = await wrapper.getItem("Conan the Librarian"); 14 | console.log(JSON.stringify(ret)); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /examples/nodejs/mongodb-examples/simple-read-aside/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/observability/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/observability/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/observability/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/observability/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/observability/config/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 5s 3 | evaluation_interval: 15s 4 | 5 | scrape_configs: 6 | - job_name: 'prometheus' 7 | static_configs: 8 | - targets: ['host.docker.internal:9464'] 9 | -------------------------------------------------------------------------------- /examples/nodejs/observability/doc-example-files/README.md: -------------------------------------------------------------------------------- 1 | This directory contains files that will be pulled in to the docs site for use in code examples. 2 | Use caution when modifying any files in this directory! 3 | -------------------------------------------------------------------------------- /examples/nodejs/observability/grafana/provisioning/dashboards/dashboards.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | providers: 4 | # an unique provider name. Required 5 | - name: 'prometheus' 6 | # Org id. Default to 1 7 | # orgId: 1 8 | # name of the dashboard folder. 9 | # folder: '' 10 | # folder UID. will be automatically generated if not specified 11 | # folderUid: '' 12 | # provider type. Default to 'file' 13 | type: file 14 | # disable dashboard deletion 15 | disableDeletion: false 16 | # how often Grafana will scan for changed dashboards 17 | updateIntervalSeconds: 10 18 | # allow updating provisioned dashboards from the UI 19 | allowUiUpdates: true 20 | options: 21 | # path to dashboard files on disk. Required when using the 'file' type 22 | path: /var/lib/grafana/dashboards 23 | # use folder names from filesystem to create folders in Grafana 24 | foldersFromFilesStructure: false 25 | -------------------------------------------------------------------------------- /examples/nodejs/observability/grafana/provisioning/datasources/datasource.yml: -------------------------------------------------------------------------------- 1 | apiVersion: 1 2 | 3 | datasources: 4 | - name: Prometheus 5 | type: prometheus 6 | url: http://prometheus:9090 7 | isDefault: true 8 | access: proxy 9 | editable: true 10 | -------------------------------------------------------------------------------- /examples/nodejs/observability/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/observability/resources/grafana_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/observability/resources/grafana_screenshot.png -------------------------------------------------------------------------------- /examples/nodejs/observability/resources/zipkin_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/nodejs/observability/resources/zipkin_screenshot.png -------------------------------------------------------------------------------- /examples/nodejs/observability/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/rate-limiter/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/rate-limiter/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | -------------------------------------------------------------------------------- /examples/nodejs/rate-limiter/rate-limiter.ts: -------------------------------------------------------------------------------- 1 | export interface RateLimiter { 2 | isLimitExceeded(id: string): Promise; 3 | } 4 | 5 | // since our rate limiting buckets are per minute, we expire keys every minute 6 | export const RATE_LIMITER_TTL_MILLIS = 60000; 7 | 8 | export abstract class AbstractRateLimiter implements RateLimiter { 9 | abstract isLimitExceeded(id: string): Promise; 10 | 11 | /** 12 | * Generates a unique key for a user (baseKey) for the current minute. This key will server as the backend 13 | * cache key where we will store the amount of calls that have been made by a user for a given minute. 14 | * @param baseKey 15 | */ 16 | generateMinuteKey(baseKey: string): string { 17 | const currentDate = new Date(); 18 | const currentMinute = currentDate.getMinutes(); 19 | return `${baseKey}_${currentMinute}`; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/nodejs/rate-limiter/service.ts: -------------------------------------------------------------------------------- 1 | export class DummyService { 2 | public doWork() { 3 | // do work here after acquiring a permit 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/nodejs/rate-limiter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | !jest.config.js 3 | *.d.ts 4 | node_modules 5 | 6 | # CDK asset staging directory 7 | .cdk.staging 8 | cdk.out 9 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts 3 | 4 | # CDK asset staging directory 5 | .cdk.staging 6 | cdk.out 7 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/infrastructure/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/authorizer/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "momento-token-vending-machine-lambda-authorizer", 3 | "version": "1.0.0", 4 | "description": "Momento token vending machine API Gateway Lambda authorizer for the Lambda function", 5 | "main": "index.ts", 6 | "scripts": { 7 | "build": "tsc", 8 | "test": "jest" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/aws-lambda": "8.10.118", 14 | "@types/node": "^16.11.4", 15 | "@typescript-eslint/eslint-plugin": "5.30.5", 16 | "@typescript-eslint/parser": "^5.0.0", 17 | "eslint": "8.19.0", 18 | "eslint-config-prettier": "8.5.0", 19 | "eslint-plugin-import": "2.26.0", 20 | "eslint-plugin-node": "11.1.0", 21 | "eslint-plugin-prettier": "4.2.1", 22 | "prettier": "2.7.1", 23 | "typescript": "4.9.5" 24 | }, 25 | "dependencies": { 26 | "@aws-sdk/client-secrets-manager": "3.485.0", 27 | "@gomomento/sdk": "^1.111.0", 28 | "aws-lambda": "1.0.7" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "momento-token-vending-machine-lambda-function", 3 | "version": "1.0.0", 4 | "description": "Momento token vending machine AWS Lambda function", 5 | "main": "index.ts", 6 | "scripts": { 7 | "build": "tsc" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/aws-lambda": "8.10.118", 13 | "@types/node": "^16.11.4", 14 | "@typescript-eslint/eslint-plugin": "5.30.5", 15 | "@typescript-eslint/parser": "^5.0.0", 16 | "eslint": "8.19.0", 17 | "eslint-config-prettier": "8.5.0", 18 | "eslint-plugin-import": "2.26.0", 19 | "eslint-plugin-node": "11.1.0", 20 | "eslint-plugin-prettier": "4.2.1", 21 | "prettier": "2.7.1", 22 | "typescript": "4.9.5" 23 | }, 24 | "dependencies": { 25 | "@aws-sdk/client-secrets-manager": "3.485.0", 26 | "@gomomento/sdk": "^1.111.0", 27 | "aws-lambda": "1.0.7" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/token-vending-machine/lambda/token-vending-machine/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/nodejs/topics/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/nodejs/topics/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/nodejs/topics/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/nodejs/topics/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/nodejs/topics/doc-example-files/cheat-sheet-main.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars */ 2 | import {TopicClient, TopicConfigurations, CredentialProvider} from '@gomomento/sdk'; 3 | 4 | function main() { 5 | const cacheClient = new TopicClient({ 6 | configuration: TopicConfigurations.Default.latest(), 7 | }); 8 | } 9 | 10 | try { 11 | main(); 12 | } catch (e) { 13 | console.error(`Uncaught exception while running example: ${JSON.stringify(e)}`); 14 | throw e; 15 | } 16 | -------------------------------------------------------------------------------- /examples/nodejs/topics/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/nodejs/topics/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/web/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento JavaScript Web SDK Examples 4 | 5 | ## Example Requirements 6 | 7 | - Node version 16 or higher is required 8 | - A Momento API key is required, you can generate one using the [Momento Console](https://console.gomomento.com) 9 | 10 | ## Examples 11 | 12 | This directory contains several subdirectories with different types of example projects: 13 | 14 | - [Cache Examples](./cache) - How to use Momento Cache 15 | - [Next.js Chat](./nextjs-chat) - How to use Momento topics and secure tokens within a Next.js application 16 | - [Vite Chat](./vite-chat-app) - How to use Momento topics and secure tokens within a static web application 17 | 18 | {{ ossFooter }} 19 | -------------------------------------------------------------------------------- /examples/web/cache/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/web/cache/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/web/cache/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/web/cache/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /examples/web/cache/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/web/cache/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/web/cache/readme.ts: -------------------------------------------------------------------------------- 1 | import {CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk-web'; 2 | import {initJSDom} from './utils/jsdom'; 3 | async function main() { 4 | // Because the Momento Web SDK is intended for use in a browser, we use the JSDom library to set up an environment 5 | // that will allow us to use it in a node.js program. 6 | initJSDom(); 7 | const cacheClient = new CacheClient({ 8 | configuration: Configurations.Laptop.v1(), 9 | credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), 10 | defaultTtlSeconds: 60, 11 | }); 12 | 13 | await cacheClient.createCache('cache'); 14 | await cacheClient.set('cache', 'foo', 'FOO'); 15 | const getResponse = await cacheClient.get('cache', 'foo'); 16 | console.log(`Value: ${getResponse.value() ?? 'CACHE MISS OR ERROR'}`); 17 | } 18 | 19 | main().catch(e => { 20 | throw e; 21 | }); 22 | -------------------------------------------------------------------------------- /examples/web/cache/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/web/cache/utils/collections.ts: -------------------------------------------------------------------------------- 1 | export function range(n: number): Array { 2 | return [...Array(n).keys()]; 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/cache/utils/time.ts: -------------------------------------------------------------------------------- 1 | export function delay(ms: number) { 2 | return new Promise(resolve => setTimeout(resolve, ms)); 3 | } 4 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "printWidth": 80, 4 | "singleQuote": false, 5 | "jsxSingleQuote": false, 6 | "semi": true, 7 | "trailingComma": "all", 8 | "tabWidth": 2 9 | } 10 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/env.d.ts: -------------------------------------------------------------------------------- 1 | namespace NodeJS { 2 | interface ProcessEnv { 3 | MOMENTO_API_KEY: string; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | 4 | } 5 | 6 | module.exports = nextConfig 7 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/web/nextjs-chat/src/app/favicon.ico -------------------------------------------------------------------------------- /examples/web/nextjs-chat/src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | :root { 6 | --foreground-rgb: 0, 0, 0; 7 | --background-start-rgb: 214, 219, 220; 8 | --background-end-rgb: 255, 255, 255; 9 | } 10 | 11 | body { 12 | color: rgb(var(--foreground-rgb)); 13 | background: linear-gradient( 14 | to bottom, 15 | transparent, 16 | rgb(var(--background-end-rgb)) 17 | ) 18 | rgb(var(--background-start-rgb)); 19 | } 20 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import "./globals.css"; 2 | import { Inter } from "next/font/google"; 3 | import NextAuthProvider from "./next-auth-provider"; 4 | 5 | const inter = Inter({ subsets: ["latin"] }); 6 | 7 | export const metadata = { 8 | title: "Momento Chat", 9 | description: "Nextjs chat application using Momento", 10 | }; 11 | 12 | export default function RootLayout({ 13 | children, 14 | }: { 15 | children: React.ReactNode; 16 | }) { 17 | return ( 18 | 19 | 20 | {children} 21 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/src/app/next-auth-provider.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { SessionProvider } from "next-auth/react"; 4 | 5 | export default function NextAuthProvider({ 6 | children, 7 | }: { 8 | children: React.ReactNode; 9 | }) { 10 | return {children}; 11 | } 12 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './src/pages/**/*.{js,ts,jsx,tsx,mdx}', 5 | './src/components/**/*.{js,ts,jsx,tsx,mdx}', 6 | './src/app/**/*.{js,ts,jsx,tsx,mdx}', 7 | ], 8 | theme: { 9 | extend: { 10 | backgroundImage: { 11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 12 | 'gradient-conic': 13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 14 | }, 15 | }, 16 | }, 17 | plugins: [], 18 | } 19 | -------------------------------------------------------------------------------- /examples/web/nextjs-chat/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | // requires the `override` keyword to override a method/property from a parent class 18 | "noImplicitOverride": true, 19 | "noFallthroughCasesInSwitch": true, 20 | "plugins": [ 21 | { 22 | "name": "next" 23 | } 24 | ], 25 | "paths": { 26 | "@/*": ["./src/*"] 27 | } 28 | }, 29 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "env.d.ts"], 30 | "exclude": ["node_modules"] 31 | } 32 | -------------------------------------------------------------------------------- /examples/web/topics/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | -------------------------------------------------------------------------------- /examples/web/topics/.gitignore: -------------------------------------------------------------------------------- 1 | advanced-middlewares-example-metrics.csv 2 | -------------------------------------------------------------------------------- /examples/web/topics/.npmignore: -------------------------------------------------------------------------------- 1 | *.ts 2 | !*.d.ts -------------------------------------------------------------------------------- /examples/web/topics/.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org/ 2 | -------------------------------------------------------------------------------- /examples/web/topics/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid", 6 | "printWidth": 120 7 | } 8 | 9 | -------------------------------------------------------------------------------- /examples/web/topics/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Momento JavaScript Web SDK - Basic Topics Examples 4 | 5 | _Read this in other languages_: [日本語](README.ja.md) 6 | 7 |
8 | 9 | ## Example Requirements 10 | 11 | - Node version 16 or higher is required 12 | - A Momento API key is required, you can generate one using the [Momento CLI](https://github.com/momentohq/momento-cli) 13 | 14 | To run any of the examples you will need to install the dependencies once first: 15 | 16 | ```bash 17 | npm install 18 | ``` 19 | 20 | ## Running the Basic Example 21 | 22 | ```bash 23 | # Run example code 24 | MOMENTO_API_KEY= npm run example 25 | ``` 26 | 27 | Example Code: [basic.ts](basic.ts) 28 | 29 | 30 | If you have questions or need help experimenting further, please reach out to us! 31 | 32 | {{ ossFooter }} 33 | -------------------------------------------------------------------------------- /examples/web/topics/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'node', 3 | roots: ['/test'], 4 | testMatch: ['**/*.test.ts'], 5 | transform: { 6 | '^.+\\.tsx?$': 'ts-jest', 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /examples/web/topics/readme.ts: -------------------------------------------------------------------------------- 1 | import {CacheClient, Configurations, CredentialProvider} from '@gomomento/sdk-web'; 2 | import {initJSDom} from './utils/jsdom'; 3 | async function main() { 4 | // Because the Momento Web SDK is intended for use in a browser, we use the JSDom library to set up an environment 5 | // that will allow us to use it in a node.js program. 6 | initJSDom(); 7 | const cacheClient = new CacheClient({ 8 | configuration: Configurations.Laptop.v1(), 9 | credentialProvider: CredentialProvider.fromEnvironmentVariable('MOMENTO_API_KEY'), 10 | defaultTtlSeconds: 60, 11 | }); 12 | 13 | await cacheClient.createCache('cache'); 14 | await cacheClient.set('cache', 'foo', 'FOO'); 15 | const getResponse = await cacheClient.get('cache', 'foo'); 16 | console.log(`Value: ${getResponse.value() ?? 'CACHE MISS OR ERROR'}`); 17 | } 18 | 19 | main().catch(e => { 20 | throw e; 21 | }); 22 | -------------------------------------------------------------------------------- /examples/web/topics/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2021", 4 | "module": "commonjs", 5 | "lib": [ 6 | "es2021", 7 | ], 8 | "declaration": true, 9 | "strict": true, 10 | "noImplicitAny": true, 11 | "strictNullChecks": true, 12 | "noImplicitThis": true, 13 | "alwaysStrict": true, 14 | "noUnusedLocals": false, 15 | "noUnusedParameters": false, 16 | "noImplicitReturns": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "inlineSourceMap": true, 19 | "inlineSources": true, 20 | "experimentalDecorators": true, 21 | "strictPropertyInitialization": false, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true, 24 | "typeRoots": [ 25 | "./node_modules/@types" 26 | ], 27 | "outDir": "./dist" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/.env.development: -------------------------------------------------------------------------------- 1 | VITE_TOKEN_VENDING_MACHINE_URL="" 2 | VITE_MOMENTO_CACHE_NAME="" 3 | VITE_TOKEN_VENDING_MACHINE_AUTH_TYPE="" 4 | 5 | 6 | # If the Token Vending Machine is using Lambda Authorizer, make sure to define these: 7 | # VITE_TOKEN_VENDING_MACHINE_USERNAME="" 8 | # VITE_TOKEN_VENDING_MACHINE_PASSWORD="" 9 | 10 | 11 | # If the Token Vending Machine is using Amazon Cognito, make sure to define these: 12 | # VITE_TOKEN_VENDING_MACHINE_CLIENT_ID="" 13 | # VITE_TOKEN_VENDING_MACHINE_AWS_REGION="" 14 | 15 | # VITE_TOKEN_VENDING_MACHINE_USERNAME_READONLY="" 16 | # VITE_TOKEN_VENDING_MACHINE_PASSWORD_READONLY="" 17 | 18 | # VITE_TOKEN_VENDING_MACHINE_USERNAME_READWRITE="" 19 | # VITE_TOKEN_VENDING_MACHINE_PASSWORD_READWRITE="" -------------------------------------------------------------------------------- /examples/web/vite-chat-app/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | src/utils 4 | src/components 5 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 3 | module.exports = { 4 | root: true, 5 | env: { browser: true, es2020: true }, 6 | extends: [ 7 | 'eslint:recommended', 8 | 'plugin:@typescript-eslint/recommended', 9 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', 10 | 'plugin:react-hooks/recommended', 11 | ], 12 | parser: '@typescript-eslint/parser', 13 | parserOptions: { 14 | ecmaVersion: 'latest', 15 | sourceType: 'module', 16 | tsconfigRootDir: __dirname, 17 | project: "./tsconfig.json", 18 | }, 19 | plugins: ['react-refresh'], 20 | rules: { 21 | 'react-refresh/only-export-components': [ 22 | 'warn', 23 | { allowConstantExport: true }, 24 | ], 25 | '@typescript-eslint/no-non-null-assertion': 'off', 26 | '@typescript-eslint/switch-exhaustiveness-check': 'error' 27 | }, 28 | } 29 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | .env 26 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Topics Chat App Demo 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/postcss.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/momentohq/client-sdk-javascript/5b1b6e693729aef3522ae9afc0d5b85e2ac9fd2c/examples/web/vite-chat-app/public/favicon.ico -------------------------------------------------------------------------------- /examples/web/vite-chat-app/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.react:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | @keyframes logo-spin { 22 | from { 23 | transform: rotate(0deg); 24 | } 25 | to { 26 | transform: rotate(360deg); 27 | } 28 | } 29 | 30 | @media (prefers-reduced-motion: no-preference) { 31 | a:nth-of-type(2) .logo { 32 | animation: logo-spin infinite 20s linear; 33 | } 34 | } 35 | 36 | .card { 37 | padding: 2em; 38 | } 39 | 40 | .read-the-docs { 41 | color: #888; 42 | } 43 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | interface ImportMetaEnv { 4 | readonly TOKEN_VENDING_MACHINE_URL: string; 5 | readonly MOMENTO_CACHE_NAME: string; 6 | } 7 | 8 | interface ImportMeta { 9 | readonly env: ImportMetaEnv; 10 | } -------------------------------------------------------------------------------- /examples/web/vite-chat-app/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/src/main.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom/client' 3 | import App from './App.tsx' 4 | import './index.css' 5 | 6 | ReactDOM.createRoot(document.getElementById('root')!).render( 7 | 8 |
9 | 10 |
11 |
, 12 | ) 13 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | darkMode: 'class', 8 | theme: { 9 | extend: { 10 | colors: { 11 | lime: { 12 | 400: '#C4F135' 13 | }, 14 | green: { 15 | 900: '#25392B', 16 | 950: '#0E2515', 17 | 1000: '#07130B', 18 | } 19 | }, 20 | fontFamily: { 21 | manrope: ['Manrope-Extrabold', 'sans-serif'], 22 | inter: ['Inter', 'sans-serif'], 23 | }, 24 | }, 25 | }, 26 | plugins: [], 27 | } 28 | 29 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 6 | "module": "ESNext", 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "react-jsx", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true, 22 | // requires the `override` keyword to override a method/property from a parent class 23 | "noImplicitOverride": true 24 | }, 25 | "include": ["src"], 26 | "references": [{ "path": "./tsconfig.node.json" }] 27 | } 28 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true, 8 | "noImplicitOverride": true, 9 | "noFallthroughCasesInSwitch": true 10 | }, 11 | "include": ["vite.config.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /examples/web/vite-chat-app/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | import EnvironmentPlugin from "vite-plugin-environment"; 4 | 5 | // https://vitejs.dev/config/ 6 | export default defineConfig({ 7 | plugins: [react(), EnvironmentPlugin("all")], 8 | }) 9 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 120000, 12 | // this reporter makes some things easier when searching canary logs because it logs 13 | // fail/success status for each test case on a single line. However it also swallows 14 | // most console output. Consider commenting out this line if you are debugging some 15 | // tests and need to see console output 16 | reporters: ["jest-spec-reporter"] 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/src/compressor-factory.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DefaultMomentoLoggerFactory, 3 | ICompression, 4 | MomentoLoggerFactory, 5 | } from '@gomomento/sdk'; 6 | import {loadZstdCompression} from './internal/compression/zstd-compression'; 7 | 8 | export class CompressorFactory { 9 | static zstd(loggerFactory?: MomentoLoggerFactory): ICompression { 10 | return loadZstdCompression( 11 | loggerFactory ?? new DefaultMomentoLoggerFactory() 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/src/index.ts: -------------------------------------------------------------------------------- 1 | export {CompressorFactory} from './compressor-factory'; 2 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression-zstd/test/unit/placeholder.test.ts: -------------------------------------------------------------------------------- 1 | describe('placeholder', () => { 2 | it("has a placeholder test so that jest won't fail when we run `npm run unit-test", () => { 3 | expect(true).toEqual(true); 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/README.template.md: -------------------------------------------------------------------------------- 1 | {{ ossHeader }} 2 | 3 | # Compression Extensions for Momento Node.js SDK 4 | 5 | This package provides extensions for the Momento Node.js SDK to support compression and decompression of data that 6 | is stored using the `CacheClient.set` function and accessed through the `CacheClient.get` function. Using compression 7 | can significantly reduce your data transfer costs if your cache values are large text values, such as JSON objects. 8 | 9 | To use the library, you will need to install it from npm: 10 | 11 | ```bash 12 | npm install @gomomento/sdk-compression 13 | ``` 14 | 15 | For more information, see: 16 | 17 | * [Momento Developer Docs - Node JS SDK Compression](https://docs.momentohq.com/sdks/nodejs/compression.html) 18 | * [NodeJS compression example](https://github.com/momentohq/client-sdk-javascript/tree/main/examples/nodejs/compression) 19 | 20 | {{ ossFooter }} 21 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 120000, 12 | // this reporter makes some things easier when searching canary logs because it logs 13 | // fail/success status for each test case on a single line. However it also swallows 14 | // most console output. Consider commenting out this line if you are debugging some 15 | // tests and need to see console output 16 | reporters: ["jest-spec-reporter"] 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/src/compressor-factory.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DefaultMomentoLoggerFactory, 3 | ICompression, 4 | MomentoLoggerFactory, 5 | } from '@gomomento/sdk'; 6 | import {loadGzipCompression} from './internal/compression/gzip-compression'; 7 | 8 | export class CompressorFactory { 9 | static default(loggerFactory?: MomentoLoggerFactory): ICompression { 10 | return loadGzipCompression( 11 | loggerFactory ?? new DefaultMomentoLoggerFactory() 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/src/index.ts: -------------------------------------------------------------------------------- 1 | export {CompressorFactory} from './compressor-factory'; 2 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs-compression/test/unit/placeholder.test.ts: -------------------------------------------------------------------------------- 1 | describe('placeholder', () => { 2 | it("has a placeholder test so that jest won't fail when we run `npm run unit-test", () => { 3 | expect(true).toEqual(true); 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test-auth-service test-cache-service test-leaderboard-service test-topics-service test-http-service test-retry-service 2 | 3 | 4 | test-auth-service: 5 | @echo "Testing auth service..." 6 | @npm run integration-test-auth 7 | 8 | 9 | test-cache-service: 10 | @echo "Testing cache service..." 11 | @npm run integration-test-cache 12 | 13 | 14 | test-leaderboard-service: 15 | @echo "Testing leaderboard service..." 16 | @npm run integration-test-leaderboard 17 | 18 | 19 | test-topics-service: 20 | @echo "Testing topics service..." 21 | @npm run integration-test-topics 22 | 23 | 24 | test-http-service: 25 | @echo "Testing http service..." 26 | @npm run integration-test-http 27 | 28 | 29 | test-retry-service: 30 | @echo "Testing automated retry service..." 31 | @npm run integration-test-retry 32 | 33 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 120000, 12 | // this reporter makes some things easier when searching canary logs because it logs 13 | // fail/success status for each test case on a single line. However it also swallows 14 | // most console output. Consider commenting out this line if you are debugging some 15 | // tests and need to see console output 16 | reporters: ["jest-spec-reporter"] 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/auth-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | import {AuthClientConfiguration} from './config/auth-client-configuration'; 3 | 4 | export interface AuthClientProps { 5 | /** 6 | * controls how the client will get authentication information for connecting to the Momento service 7 | */ 8 | credentialProvider?: CredentialProvider; 9 | 10 | /** 11 | * Controls the configuration settings for the auth client, such as logging configuration. 12 | */ 13 | configuration?: AuthClientConfiguration; 14 | 15 | /** 16 | * Configures whether the client should return a Momento Error object or throw an exception when an 17 | * error occurs. By default, this is set to false, and the client will return a Momento Error object on errors. Set it 18 | * to true if you prefer for exceptions to be thrown. 19 | */ 20 | throwOnErrors?: boolean; 21 | } 22 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/batchutils/batch-props.ts: -------------------------------------------------------------------------------- 1 | import {CacheGet, CacheSet, CacheDelete} from '@gomomento/sdk-core'; 2 | 3 | export const defaultMaxConcurrentRequests = 5; 4 | export const defaultTtlSeconds = 60; 5 | 6 | export interface BatchFunctionOptions { 7 | maxConcurrentRequests?: number; 8 | } 9 | 10 | export type BatchGetOptions = BatchFunctionOptions; 11 | 12 | export type BatchGetResponse = Record; 13 | 14 | export type BatchSetOptions = BatchFunctionOptions; 15 | 16 | export interface BatchSetItem { 17 | key: string | Uint8Array; 18 | value: string | Uint8Array; 19 | ttl?: number; 20 | } 21 | 22 | export type BatchSetResponse = Record; 23 | 24 | export type BatchDeleteOptions = BatchFunctionOptions; 25 | 26 | export type BatchDeleteResponse = Record; 27 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/auth-client-configuration.ts: -------------------------------------------------------------------------------- 1 | import {MomentoLoggerFactory} from '@gomomento/sdk-core'; 2 | 3 | export interface AuthClientConfigurationProps { 4 | /** 5 | * Configures logging verbosity and format 6 | */ 7 | loggerFactory: MomentoLoggerFactory; 8 | } 9 | 10 | /** 11 | * Configuration options for Momento CacheClient. 12 | * 13 | * @export 14 | * @interface Configuration 15 | */ 16 | export interface AuthConfiguration { 17 | /** 18 | * @returns {MomentoLoggerFactory} the current configuration options for logging verbosity and format 19 | */ 20 | getLoggerFactory(): MomentoLoggerFactory; 21 | } 22 | 23 | export class AuthClientConfiguration implements AuthConfiguration { 24 | private readonly loggerFactory: MomentoLoggerFactory; 25 | 26 | constructor(props: AuthClientConfigurationProps) { 27 | this.loggerFactory = props.loggerFactory; 28 | } 29 | 30 | getLoggerFactory(): MomentoLoggerFactory { 31 | return this.loggerFactory; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/retry/eligibility-strategy.ts: -------------------------------------------------------------------------------- 1 | import {Metadata, StatusObject} from '@grpc/grpc-js'; 2 | import {ClientMethodDefinition} from '@grpc/grpc-js/build/src/make-client'; 3 | 4 | export interface EligibleForRetryProps { 5 | grpcStatus: StatusObject; 6 | grpcRequest: ClientMethodDefinition; 7 | requestMetadata: Metadata; 8 | } 9 | 10 | export interface EligibilityStrategy { 11 | isEligibleForRetry(props: EligibleForRetryProps): boolean; 12 | } 13 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/retry/no-retry-strategy.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DeterminewhenToRetryRequestProps, 3 | RetryStrategy, 4 | } from './retry-strategy'; 5 | import {MomentoLoggerFactory, MomentoLogger} from '../../'; 6 | 7 | export interface NoRetryStrategyProps { 8 | loggerFactory: MomentoLoggerFactory; 9 | } 10 | 11 | export class NoRetryStrategy implements RetryStrategy { 12 | private readonly logger: MomentoLogger; 13 | 14 | constructor(props: NoRetryStrategyProps) { 15 | this.logger = props.loggerFactory.getLogger(this); 16 | } 17 | 18 | determineWhenToRetryRequest( 19 | props: DeterminewhenToRetryRequestProps 20 | ): number | null { 21 | this.logger.debug( 22 | `Using no-retry strategy, therefore not retrying request; status code: ${props.grpcStatus.code}, request type: ${props.grpcRequest.path}, attemptNumber: ${props.attemptNumber}` 23 | ); 24 | // null means do not retry 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/retry/retry-strategy.ts: -------------------------------------------------------------------------------- 1 | import {Metadata, StatusObject} from '@grpc/grpc-js'; 2 | import {ClientMethodDefinition} from '@grpc/grpc-js/build/src/make-client'; 3 | 4 | export interface DeterminewhenToRetryRequestProps { 5 | grpcStatus: StatusObject; 6 | grpcRequest: ClientMethodDefinition; 7 | attemptNumber: number; 8 | requestMetadata: Metadata; 9 | overallDeadline: Date; 10 | } 11 | 12 | export interface RetryStrategy { 13 | responseDataReceivedTimeoutMillis?: number; 14 | 15 | determineWhenToRetryRequest( 16 | props: DeterminewhenToRetryRequestProps 17 | ): number | null; 18 | } 19 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/transport/cache/index.ts: -------------------------------------------------------------------------------- 1 | export * from './grpc-configuration'; 2 | export * from './transport-strategy'; 3 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/transport/storage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './grpc-configuration'; 2 | export * from './transport-strategy'; 3 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/config/transport/topics/index.ts: -------------------------------------------------------------------------------- 1 | export * from './grpc-configuration'; 2 | export * from './transport-strategy'; 3 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/errors/compression-error.ts: -------------------------------------------------------------------------------- 1 | import {SdkError} from '@gomomento/sdk-core'; 2 | 3 | export class CompressionError extends SdkError { 4 | override _messageWrapper = 'Compression Error'; 5 | constructor(action: string, option: string) { 6 | super( 7 | `Compressor is not set, but \`${action}\` was called with the \`${option}\` option; please install @gomomento/sdk-nodejs-compression and call \`Configuration.withCompressionStrategy\` to enable compression.` 8 | ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/auth-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {AuthClientProps} from '../auth-client-props'; 3 | 4 | export interface AuthClientAllProps extends AuthClientProps { 5 | credentialProvider: CredentialProvider; 6 | } 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/cache-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {CacheClientProps} from '../cache-client-props'; 3 | import {Configuration} from '../config/configuration'; 4 | 5 | export interface CacheClientAllProps extends CacheClientProps { 6 | configuration: Configuration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/grpc/grpc-client-wrapper.ts: -------------------------------------------------------------------------------- 1 | import {Channel} from '@grpc/grpc-js'; 2 | 3 | export interface CloseableGrpcClient { 4 | close(): void; 5 | } 6 | 7 | export interface GrpcClientWrapper { 8 | getClient(): T; 9 | } 10 | 11 | export interface GrpcClientWithChannel extends CloseableGrpcClient { 12 | getChannel(): Channel; 13 | } 14 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/leaderboard-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {LeaderboardClientProps} from '../leaderboard-client-props'; 2 | import {LeaderboardConfiguration} from '../config/leaderboard-configuration'; 3 | import {CredentialProvider} from '@gomomento/sdk-core'; 4 | 5 | export interface LeaderboardClientAllProps extends LeaderboardClientProps { 6 | configuration: LeaderboardConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/storage-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {StorageConfiguration} from '../config/storage-configuration'; 3 | import {StorageClientProps} from '../storage-client-props'; 4 | 5 | export interface StorageClientAllProps extends StorageClientProps { 6 | configuration: StorageConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/topic-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {TopicClientProps} from '../topic-client-props'; 2 | import {TopicConfiguration} from '../config/topic-configuration'; 3 | import {CredentialProvider} from '@gomomento/sdk-core'; 4 | 5 | export interface TopicClientAllProps extends TopicClientProps { 6 | configuration: TopicConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/utils.ts: -------------------------------------------------------------------------------- 1 | export function convert(v: string | Uint8Array): Uint8Array { 2 | if (typeof v === 'string') { 3 | return new TextEncoder().encode(v); 4 | } 5 | return v; 6 | } 7 | 8 | export function getCurrentTimeAsDateObject(): Date { 9 | return new Date(); 10 | } 11 | 12 | export function createDateObjectFromUnixMillisTimestamp( 13 | unixMillisTimestamp: number 14 | ): Date { 15 | return new Date(unixMillisTimestamp); 16 | } 17 | 18 | export function hasExceededDeadlineRelativeToNow(overallDeadline: Date) { 19 | return getCurrentTimeAsDateObject() >= overallDeadline; 20 | } 21 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/internal/vendor/printf/printf.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for printf 0.2.5 and above 2 | // Project: http://www.adaltas.com/projects/node-printf 3 | // Definitions by: Aluísio Augusto Silva Gonçalves 4 | 5 | /// 6 | 7 | export = printf; 8 | declare function printf(format: string, ...args: any[]): string; 9 | declare function printf(writeStream: NodeJS.WritableStream, format: string, ...args: any[]): void; 10 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/leaderboard-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider, LeaderboardConfiguration} from '.'; 2 | 3 | export interface LeaderboardClientProps { 4 | /** 5 | * Configuration settings for the leaderboard client 6 | */ 7 | configuration?: LeaderboardConfiguration; 8 | /** 9 | * controls how the client will get authentication information for connecting to the Momento service 10 | */ 11 | credentialProvider?: CredentialProvider; 12 | } 13 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/storage-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {StorageConfiguration} from './config/storage-configuration'; 3 | 4 | export interface StorageClientProps { 5 | credentialProvider?: CredentialProvider; 6 | configuration?: StorageConfiguration; 7 | } 8 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/src/topic-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | import {TopicConfiguration} from './config/topic-configuration'; 3 | 4 | export interface TopicClientProps { 5 | /** 6 | * Configuration settings for the topic client 7 | */ 8 | configuration?: TopicConfiguration; 9 | /** 10 | * controls how the client will get authentication information for connecting to the Momento service 11 | */ 12 | credentialProvider?: CredentialProvider; 13 | } 14 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/auth/auth-client.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupAuthClientIntegrationTest} from '../../integration-setup'; 2 | import {runAuthClientTests} from '@gomomento/common-integration-tests'; 3 | 4 | const { 5 | mgaAccountSessionTokenAuthClient, 6 | legacyTokenAuthClient, 7 | mgaAccountSessionTokenCacheClient, 8 | mgaAccountSessionTokenTopicClient, 9 | authTokenAuthClientFactory, 10 | cacheClientFactory, 11 | topicClientFactory, 12 | cacheName, 13 | } = SetupAuthClientIntegrationTest(); 14 | 15 | runAuthClientTests( 16 | mgaAccountSessionTokenAuthClient, 17 | legacyTokenAuthClient, 18 | mgaAccountSessionTokenCacheClient, 19 | mgaAccountSessionTokenTopicClient, 20 | authTokenAuthClientFactory, 21 | cacheClientFactory, 22 | topicClientFactory, 23 | cacheName 24 | ); 25 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/batch-get-set.test.ts: -------------------------------------------------------------------------------- 1 | import {runBatchGetSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, cacheClientWithThrowOnErrors, integrationTestCacheName} = 5 | SetupIntegrationTest(); 6 | 7 | runBatchGetSetTests( 8 | cacheClient, 9 | cacheClientWithThrowOnErrors, 10 | integrationTestCacheName 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/create-delete-list-cache.test.ts: -------------------------------------------------------------------------------- 1 | import {runCreateDeleteListCacheTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient} = SetupIntegrationTest(); 5 | 6 | runCreateDeleteListCacheTests(cacheClient); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/dictionary.test.ts: -------------------------------------------------------------------------------- 1 | import {runDictionaryTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runDictionaryTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/get-set-delete.test.ts: -------------------------------------------------------------------------------- 1 | import {runGetSetDeleteTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | cacheClient, 6 | cacheClientWithThrowOnErrors, 7 | cacheClientWithBalancedReadConcern, 8 | cacheClientWithConsistentReadConcern, 9 | integrationTestCacheName, 10 | } = SetupIntegrationTest(); 11 | 12 | runGetSetDeleteTests( 13 | cacheClient, 14 | cacheClientWithThrowOnErrors, 15 | cacheClientWithBalancedReadConcern, 16 | cacheClientWithConsistentReadConcern, 17 | integrationTestCacheName 18 | ); 19 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/item-get-ttl.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runItemGetTtlTest} from '@gomomento/common-integration-tests'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runItemGetTtlTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/item-get-type.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runItemGetTypeTest} from '@gomomento/common-integration-tests'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runItemGetTypeTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/keys-exist.test.ts: -------------------------------------------------------------------------------- 1 | import {runKeysExistTest} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runKeysExistTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/list.test.ts: -------------------------------------------------------------------------------- 1 | import {runListTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runListTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/replica-reads.test.ts: -------------------------------------------------------------------------------- 1 | import {runReplicaReadTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClientWithBalancedReadConcern, integrationTestCacheName} = 5 | SetupIntegrationTest(); 6 | 7 | runReplicaReadTests( 8 | cacheClientWithBalancedReadConcern, 9 | integrationTestCacheName 10 | ); 11 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/set.test.ts: -------------------------------------------------------------------------------- 1 | import {runSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runSetTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/sorted-set.test.ts: -------------------------------------------------------------------------------- 1 | import {runSortedSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runSortedSetTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/cache/update-ttl.test.ts: -------------------------------------------------------------------------------- 1 | import {runUpdateTtlTest} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runUpdateTtlTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/http/http-apis.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runHttpApiTest} from '@gomomento/common-integration-tests/dist/src/http/http-apis'; 3 | 4 | const {credentialProvider, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runHttpApiTest(credentialProvider, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/leaderboard/leaderboard.test.ts: -------------------------------------------------------------------------------- 1 | import {runLeaderboardClientTests} from '@gomomento/common-integration-tests'; 2 | import {SetupLeaderboardIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | leaderboardClient, 6 | leaderboardClientWithThrowOnErrors, 7 | integrationTestCacheName, 8 | } = SetupLeaderboardIntegrationTest(); 9 | 10 | runLeaderboardClientTests( 11 | leaderboardClient, 12 | leaderboardClientWithThrowOnErrors, 13 | integrationTestCacheName 14 | ); 15 | -------------------------------------------------------------------------------- /packages/client-sdk-nodejs/test/integration/shared/topics/topic-client.test.ts: -------------------------------------------------------------------------------- 1 | import {runTopicClientTests} from '@gomomento/common-integration-tests'; 2 | import {SetupTopicIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | topicClient, 6 | topicClientWithThrowOnErrors, 7 | cacheClient, 8 | integrationTestCacheName, 9 | } = SetupTopicIntegrationTest(); 10 | runTopicClientTests( 11 | topicClient, 12 | topicClientWithThrowOnErrors, 13 | cacheClient, 14 | integrationTestCacheName 15 | ); 16 | -------------------------------------------------------------------------------- /packages/client-sdk-web/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | jest.setup.js 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/client-sdk-web/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: test-auth-service test-cache-service test-leaderboard-service test-topics-service test-http-service 2 | 3 | 4 | test-auth-service: 5 | @echo "Testing auth service..." 6 | @npm run integration-test-auth 7 | 8 | 9 | test-cache-service: 10 | @echo "Testing cache service..." 11 | @npm run integration-test-cache 12 | 13 | 14 | test-leaderboard-service: 15 | @echo "Testing leaderboard service..." 16 | @npm run integration-test-leaderboard 17 | 18 | 19 | test-topics-service: 20 | @echo "Testing topics service..." 21 | @npm run integration-test-topics 22 | 23 | test-http-service: 24 | @echo "Testing http service..." 25 | @npm run integration-test-http 26 | -------------------------------------------------------------------------------- /packages/client-sdk-web/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'jsdom', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 120000, 12 | setupFiles: ['/jest.setup.js'], 13 | moduleNameMapper: { 14 | // Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451 15 | "uuid": require.resolve('uuid'), 16 | }, 17 | // this reporter makes some things easier when searching canary logs because it logs 18 | // fail/success status for each test case on a single line. However it also swallows 19 | // most console output. Consider commenting out this line if you are debugging some 20 | // tests and need to see console output 21 | reporters: ["jest-spec-reporter"] 22 | }; 23 | 24 | export default config; 25 | -------------------------------------------------------------------------------- /packages/client-sdk-web/jest.setup.js: -------------------------------------------------------------------------------- 1 | const util = require('util'); 2 | 3 | // ref: https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom 4 | // ref: https://github.com/jsdom/jsdom/issues/2524 5 | 6 | // Generally speaking, we don't want to have these polyfills here. However, TextEncoder and 7 | // TextDecoder are supported by all modern broswers, the only "modern" browser that is it not supported 8 | // in is IE 11, which is at EOL and retired June 2022 RIP. https://www.lambdatest.com/web-technologies/textencoder. 9 | Object.defineProperty(window, 'TextEncoder', { 10 | writable: true, 11 | value: util.TextEncoder 12 | }) 13 | Object.defineProperty(window, 'TextDecoder', { 14 | writable: true, 15 | value: util.TextDecoder 16 | }) 17 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/auth-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | 3 | export interface AuthClientProps { 4 | /** 5 | * controls how the client will get authentication information for connecting to the Momento service 6 | */ 7 | credentialProvider?: CredentialProvider; 8 | 9 | /** 10 | * Configures whether the client should return a Momento Error object or throw an exception when an 11 | * error occurs. By default, this is set to false, and the client will return a Momento Error object on errors. Set it 12 | * to true if you prefer for exceptions to be thrown. 13 | */ 14 | throwOnErrors?: boolean; 15 | } 16 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/auth-client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | AbstractAuthClient, 3 | IAuthClient, 4 | } from '@gomomento/sdk-core/dist/src/internal/clients/index'; 5 | import {InternalWebGrpcAuthClient} from './internal/auth-client'; 6 | import {AuthClientProps} from './auth-client-props'; 7 | import {AuthClientAllProps} from './internal/auth-client-all-props'; 8 | import {getDefaultCredentialProvider} from '@gomomento/sdk-core'; 9 | 10 | export class AuthClient extends AbstractAuthClient { 11 | constructor(props?: AuthClientProps) { 12 | const createAuthClient = (): IAuthClient => { 13 | const allProps: AuthClientAllProps = { 14 | ...props, 15 | credentialProvider: 16 | props?.credentialProvider ?? getDefaultCredentialProvider(), 17 | }; 18 | return new InternalWebGrpcAuthClient(allProps); 19 | }; 20 | super({createAuthClient}); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/cache-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | import {Configuration} from './config/configuration'; 3 | 4 | export interface CacheClientProps { 5 | /** 6 | * Configuration settings for the cache client 7 | */ 8 | configuration?: Configuration; 9 | /** 10 | * controls how the client will get authentication information for connecting to the Momento service 11 | */ 12 | credentialProvider?: CredentialProvider; 13 | /** 14 | * the default time to live of object inside of cache, in seconds 15 | */ 16 | defaultTtlSeconds: number; 17 | } 18 | 19 | /** 20 | * @deprecated use {CacheClientProps} instead 21 | */ 22 | export type SimpleCacheClientProps = CacheClientProps; 23 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/config/storage-configuration.ts: -------------------------------------------------------------------------------- 1 | import {MomentoLoggerFactory} from '@gomomento/sdk-core'; 2 | 3 | export interface StorageConfigurationProps { 4 | /** 5 | * Configures logging verbosity and format 6 | */ 7 | loggerFactory: MomentoLoggerFactory; 8 | } 9 | 10 | /** 11 | * Configuration options for Momento StorageClient 12 | * 13 | * @export 14 | * @interface StorageConfiguration 15 | */ 16 | export interface StorageConfiguration { 17 | /** 18 | * @returns {MomentoLoggerFactory} the current configuration options for logging verbosity and format 19 | */ 20 | getLoggerFactory(): MomentoLoggerFactory; 21 | } 22 | 23 | export class StorageClientConfiguration implements StorageConfiguration { 24 | private readonly loggerFactory: MomentoLoggerFactory; 25 | 26 | constructor(props: StorageConfigurationProps) { 27 | this.loggerFactory = props.loggerFactory; 28 | } 29 | 30 | getLoggerFactory(): MomentoLoggerFactory { 31 | return this.loggerFactory; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/config/transport/grpc-configuration.ts: -------------------------------------------------------------------------------- 1 | export interface GrpcConfigurationProps { 2 | /** 3 | * number of milliseconds the client is willing to wait for an RPC to complete before it is terminated 4 | * with a DeadlineExceeded error. 5 | */ 6 | deadlineMillis: number; 7 | } 8 | 9 | /** 10 | * Encapsulates gRPC configuration tunables. 11 | * @export 12 | * @interface GrpcConfiguration 13 | */ 14 | export interface GrpcConfiguration { 15 | /** 16 | * @returns {number} number of milliseconds the client is willing to wait for an RPC to complete before it is terminated 17 | * with a DeadlineExceeded error. 18 | */ 19 | getDeadlineMillis(): number; 20 | 21 | /** 22 | * Copy constructor for overriding the client-side deadline 23 | * @param {number} deadlineMillis 24 | * @returns {GrpcConfiguration} a new GrpcConfiguration with the specified client-side deadline 25 | */ 26 | withDeadlineMillis(deadlineMillis: number): GrpcConfiguration; 27 | } 28 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/config/transport/index.ts: -------------------------------------------------------------------------------- 1 | export * from './grpc-configuration'; 2 | export * from './transport-strategy'; 3 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/internal/auth-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {AuthClientProps} from '../auth-client-props'; 3 | 4 | export interface AuthClientAllProps extends AuthClientProps { 5 | credentialProvider: CredentialProvider; 6 | } 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/internal/cache-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {CacheClientProps} from '../cache-client-props'; 3 | import {Configuration} from '../config/configuration'; 4 | 5 | export interface CacheClientAllProps extends CacheClientProps { 6 | configuration: Configuration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/internal/leaderboard-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {LeaderboardClientProps} from '../leaderboard-client-props'; 2 | import {LeaderboardConfiguration} from '../config/leaderboard-configuration'; 3 | import {CredentialProvider} from '@gomomento/sdk-core'; 4 | 5 | export interface LeaderboardClientAllProps extends LeaderboardClientProps { 6 | configuration: LeaderboardConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/internal/storage-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '@gomomento/sdk-core'; 2 | import {StorageClientProps} from '../storage-client-props'; 3 | import {StorageConfiguration} from '../config/storage-configuration'; 4 | 5 | export interface StorageClientAllProps extends StorageClientProps { 6 | configuration: StorageConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/internal/topic-client-all-props.ts: -------------------------------------------------------------------------------- 1 | import {TopicClientProps} from '../topic-client-props'; 2 | import {TopicConfiguration} from '../config/topic-configuration'; 3 | import {CredentialProvider} from '@gomomento/sdk-core'; 4 | 5 | export interface TopicClientAllProps extends TopicClientProps { 6 | configuration: TopicConfiguration; 7 | credentialProvider: CredentialProvider; 8 | } 9 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/leaderboard-client-props.ts: -------------------------------------------------------------------------------- 1 | import {LeaderboardConfiguration, CredentialProvider} from '.'; 2 | 3 | export interface LeaderboardClientProps { 4 | /** 5 | * Configuration settings for the leaderboard client 6 | */ 7 | configuration?: LeaderboardConfiguration; 8 | /** 9 | * controls how the client will get authentication information for connecting to the Momento service 10 | */ 11 | credentialProvider?: CredentialProvider; 12 | } 13 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/storage-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | import {StorageConfiguration} from './config/storage-configuration'; 3 | 4 | export interface StorageClientProps { 5 | /** 6 | * Configuration settings for the storage client 7 | */ 8 | configuration?: StorageConfiguration; 9 | /** 10 | * controls how the client will get authentication information for connecting to the Momento service 11 | */ 12 | credentialProvider?: CredentialProvider; 13 | } 14 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/topic-client-props.ts: -------------------------------------------------------------------------------- 1 | import {CredentialProvider} from '.'; 2 | import {TopicConfiguration} from './config/topic-configuration'; 3 | 4 | export interface TopicClientProps { 5 | /** 6 | * Configuration settings for the topic client 7 | */ 8 | configuration?: TopicConfiguration; 9 | /** 10 | * controls how the client will get authentication information for connecting to the Momento service 11 | */ 12 | credentialProvider?: CredentialProvider; 13 | } 14 | -------------------------------------------------------------------------------- /packages/client-sdk-web/src/utils/auth.ts: -------------------------------------------------------------------------------- 1 | import {InternalSuperUserPermissions} from '@gomomento/sdk-core/dist/src/internal/utils/auth'; 2 | 3 | export {InternalSuperUserPermissions}; 4 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/auth/auth-client.test.ts: -------------------------------------------------------------------------------- 1 | import {runAuthClientTests} from '@gomomento/common-integration-tests'; 2 | import {SetupAuthClientIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | mgaAccountSessionTokenAuthClient, 6 | legacyTokenAuthClient, 7 | mgaAccountSessionTokenCacheClient, 8 | mgaAccountSessionTokenTopicClient, 9 | authTokenAuthClientFactory, 10 | cacheClientFactory, 11 | topicClientFactory, 12 | cacheName, 13 | } = SetupAuthClientIntegrationTest(); 14 | 15 | runAuthClientTests( 16 | mgaAccountSessionTokenAuthClient, 17 | legacyTokenAuthClient, 18 | mgaAccountSessionTokenCacheClient, 19 | mgaAccountSessionTokenTopicClient, 20 | authTokenAuthClientFactory, 21 | cacheClientFactory, 22 | topicClientFactory, 23 | cacheName 24 | ); 25 | 26 | // Not running for now, will fast follow once we figure out 27 | // why the web SDK integration tests for disposable tokens 28 | // are failing with "Insufficient permissions" errors 29 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/batch-get-set.test.ts: -------------------------------------------------------------------------------- 1 | import {runBatchGetSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, cacheClientWithThrowOnErrors, integrationTestCacheName} = 5 | SetupIntegrationTest(); 6 | 7 | runBatchGetSetTests( 8 | cacheClient, 9 | cacheClientWithThrowOnErrors, 10 | integrationTestCacheName 11 | ); 12 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/create-delete-list-cache.test.ts: -------------------------------------------------------------------------------- 1 | import {runCreateDeleteListCacheTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient} = SetupIntegrationTest(); 5 | 6 | runCreateDeleteListCacheTests(cacheClient); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/dictionary.test.ts: -------------------------------------------------------------------------------- 1 | import {runDictionaryTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runDictionaryTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/get-set-delete.test.ts: -------------------------------------------------------------------------------- 1 | import {runGetSetDeleteTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | cacheClient, 6 | cacheClientWithThrowOnErrors, 7 | cacheClientWithBalancedReadConcern, 8 | cacheClientWithConsistentReadConcern, 9 | integrationTestCacheName, 10 | } = SetupIntegrationTest(); 11 | 12 | runGetSetDeleteTests( 13 | cacheClient, 14 | cacheClientWithThrowOnErrors, 15 | cacheClientWithBalancedReadConcern, 16 | cacheClientWithConsistentReadConcern, 17 | integrationTestCacheName 18 | ); 19 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/item-get-ttl.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runItemGetTtlTest} from '@gomomento/common-integration-tests'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runItemGetTtlTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/item-get-type.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runItemGetTypeTest} from '@gomomento/common-integration-tests'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runItemGetTypeTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/keys-exist.test.ts: -------------------------------------------------------------------------------- 1 | import {runKeysExistTest} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runKeysExistTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/list.test.ts: -------------------------------------------------------------------------------- 1 | import {runListTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runListTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/replica-reads.test.ts: -------------------------------------------------------------------------------- 1 | import {runReplicaReadTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClientWithBalancedReadConcern, integrationTestCacheName} = 5 | SetupIntegrationTest(); 6 | 7 | runReplicaReadTests( 8 | cacheClientWithBalancedReadConcern, 9 | integrationTestCacheName 10 | ); 11 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/set.test.ts: -------------------------------------------------------------------------------- 1 | import {runSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runSetTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/sorted-set.test.ts: -------------------------------------------------------------------------------- 1 | import {runSortedSetTests} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runSortedSetTests(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/cache/update-ttl.test.ts: -------------------------------------------------------------------------------- 1 | import {runUpdateTtlTest} from '@gomomento/common-integration-tests'; 2 | import {SetupIntegrationTest} from '../../integration-setup'; 3 | 4 | const {cacheClient, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runUpdateTtlTest(cacheClient, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/http/http-api.test.ts: -------------------------------------------------------------------------------- 1 | import {SetupIntegrationTest} from '../../integration-setup'; 2 | import {runHttpApiTest} from '@gomomento/common-integration-tests/dist/src/http/http-apis'; 3 | 4 | const {credentialProvider, integrationTestCacheName} = SetupIntegrationTest(); 5 | 6 | runHttpApiTest(credentialProvider, integrationTestCacheName); 7 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/leaderboard/leaderboard.test.ts: -------------------------------------------------------------------------------- 1 | import {runLeaderboardClientTests} from '@gomomento/common-integration-tests'; 2 | import {SetupLeaderboardIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | leaderboardClient, 6 | leaderboardClientWithThrowOnErrors, 7 | integrationTestCacheName, 8 | } = SetupLeaderboardIntegrationTest(); 9 | 10 | runLeaderboardClientTests( 11 | leaderboardClient, 12 | leaderboardClientWithThrowOnErrors, 13 | integrationTestCacheName 14 | ); 15 | -------------------------------------------------------------------------------- /packages/client-sdk-web/test/integration/shared/topics/topic-client.test.ts: -------------------------------------------------------------------------------- 1 | import {runTopicClientTests} from '@gomomento/common-integration-tests'; 2 | import {SetupTopicIntegrationTest} from '../../integration-setup'; 3 | 4 | const { 5 | topicClient, 6 | topicClientWithThrowOnErrors, 7 | cacheClient, 8 | integrationTestCacheName, 9 | } = SetupTopicIntegrationTest(); 10 | runTopicClientTests( 11 | topicClient, 12 | topicClientWithThrowOnErrors, 13 | cacheClient, 14 | integrationTestCacheName 15 | ); 16 | -------------------------------------------------------------------------------- /packages/common-integration-tests/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | -------------------------------------------------------------------------------- /packages/common-integration-tests/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/common-integration-tests/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['/src/momento-jest-matchers.ts'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 120000, 12 | // this reporter makes some things easier when searching canary logs because it logs 13 | // fail/success status for each test case on a single line. However it also swallows 14 | // most console output. Consider commenting out this line if you are debugging some 15 | // tests and need to see console output 16 | reporters: ["jest-spec-reporter"] 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /packages/common-integration-tests/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './common-int-test-utils'; 2 | export * from './cache/create-delete-list-cache'; 3 | export * from './cache/get-set-delete'; 4 | export * from './auth/auth-client'; 5 | export * from './cache/list'; 6 | export * from './cache/dictionary'; 7 | export * from './cache/set'; 8 | export * from './cache/sorted-set'; 9 | export * from './cache/item-get-ttl'; 10 | export * from './cache/item-get-type'; 11 | export * from './topics/topic-client'; 12 | export * from './cache/keys-exist'; 13 | export * from './cache/update-ttl'; 14 | export * from './leaderboard/leaderboard-client'; 15 | export * from './cache/batch-get-set'; 16 | export * from './cache/replica-reads'; 17 | -------------------------------------------------------------------------------- /packages/common-integration-tests/test/unit/placeholder.test.ts: -------------------------------------------------------------------------------- 1 | describe('placeholder', () => { 2 | it('should pass', () => { 3 | console.log('yay'); 4 | }); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/core/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | **/*.d.ts 4 | examples 5 | jest*.config.ts 6 | -------------------------------------------------------------------------------- /packages/core/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5", 5 | "arrowParens": "avoid" 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/core/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type {Config} from 'jest'; 2 | 3 | const config: Config = { 4 | setupFilesAfterEnv: ['jest-extended/all'], 5 | testEnvironment: 'node', 6 | roots: ['/test'], 7 | testMatch: ['**/*.test.ts'], 8 | transform: { 9 | '^.+\\.tsx?$': 'ts-jest', 10 | }, 11 | testTimeout: 30000, 12 | // this reporter makes some things easier when searching canary logs because it logs 13 | // fail/success status for each test case on a single line. However it also swallows 14 | // most console output. Consider commenting out this line if you are debugging some 15 | // tests and need to see console output 16 | reporters: ["jest-spec-reporter"] 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /packages/core/src/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './credential-provider'; 2 | -------------------------------------------------------------------------------- /packages/core/src/clients/ILeaderboardClient.ts: -------------------------------------------------------------------------------- 1 | import {ILeaderboard} from './ILeaderboard'; 2 | 3 | export interface ILeaderboardClient { 4 | leaderboard(cacheName: string, leaderboardName: string): ILeaderboard; 5 | close(): void; 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/src/compression/compression-level.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * When compressing a value, you may choose between these different modes to control the trade-off between compressionLevel speed and compressionLevel ratio. 3 | */ 4 | export enum CompressionLevel { 5 | /** 6 | * Provides a good balance between compression speed and compression ratio. 7 | * @type {CompressionLevel.Balanced} 8 | */ 9 | Balanced = 'Balanced', 10 | /** 11 | * Provides the fastest compression speed, prioritizing reduction in CPU usage over compression ratio. 12 | * @type {CompressionLevel.Fastest} 13 | */ 14 | Fastest = 'Fastest', 15 | /** 16 | * Provides the best compression ratio, prioritizing reduction in storage space over compression speed. 17 | * @type {CompressionLevel.SmallestSize} 18 | */ 19 | SmallestSize = 'SmallestSize', 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/src/config/logging/index.ts: -------------------------------------------------------------------------------- 1 | export * from './momento-logger'; 2 | export * from './noop-momento-logger'; 3 | -------------------------------------------------------------------------------- /packages/core/src/config/logging/momento-logger.ts: -------------------------------------------------------------------------------- 1 | export interface MomentoLogger { 2 | error(msg: string, ...args: unknown[]): void; 3 | warn(msg: string, ...args: unknown[]): void; 4 | info(msg: string, ...args: unknown[]): void; 5 | debug(msg: string, ...args: unknown[]): void; 6 | trace(msg: string, ...args: unknown[]): void; 7 | } 8 | 9 | export interface MomentoLoggerFactory { 10 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 11 | getLogger(loggerName: string | any): MomentoLogger; 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/src/config/read-concern.ts: -------------------------------------------------------------------------------- 1 | export enum ReadConcern { 2 | // BALANCED is the default read concern for the cache client. 3 | BALANCED = 'balanced', 4 | // CONSISTENT read concern guarantees read after write consistency. 5 | CONSISTENT = 'consistent', 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/src/errors/ICacheServiceErrorMapper.ts: -------------------------------------------------------------------------------- 1 | import {SdkError} from '../../src'; 2 | 3 | export interface ResolveOrRejectErrorOptions { 4 | err: TGrpcError | null; 5 | errorResponseFactoryFn: (err: SdkError) => unknown; 6 | // eslint-disable-next-line @typescript-eslint/no-explicit-any 7 | resolveFn: (result: any) => void; 8 | rejectFn: (err: SdkError) => void; 9 | } 10 | 11 | export interface ICacheServiceErrorMapper { 12 | resolveOrRejectError(opts: ResolveOrRejectErrorOptions): void; 13 | returnOrThrowError( 14 | err: Error, 15 | errorResponseFactoryFn: (err: SdkError) => TErrorResponse 16 | ): TErrorResponse; 17 | convertError(err: TGrpcError | null): SdkError; 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/src/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './errors'; 2 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/auth/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AbstractAuthClient'; 2 | export * from '../../../clients/IAuthClient'; 3 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/cache/IControlClient.ts: -------------------------------------------------------------------------------- 1 | import {CacheFlush, CreateCache, DeleteCache, ListCaches} from '../../../index'; 2 | 3 | export interface IControlClient { 4 | createCache(cacheName: string): Promise; 5 | deleteCache(cacheName: string): Promise; 6 | listCaches(): Promise; 7 | flushCache(cacheName: string): Promise; 8 | close(): void; 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/cache/IPingClient.ts: -------------------------------------------------------------------------------- 1 | export interface IPingClient { 2 | ping(): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/cache/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AbstractCacheClient'; 2 | export * from '../../../clients/ICacheClient'; 3 | export * from './IControlClient'; 4 | export * from './IDataClient'; 5 | export * from './IPingClient'; 6 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cache'; 2 | export * from './auth'; 3 | export * from './pubsub'; 4 | export * from './leaderboard'; 5 | export * from './storage'; 6 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/leaderboard/index.ts: -------------------------------------------------------------------------------- 1 | export * from '../../../clients/ILeaderboard'; 2 | export * from '../../../clients/ILeaderboardClient'; 3 | export * from './AbstractLeaderboard'; 4 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/pubsub/IPubsubClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | TopicPublish, 3 | TopicSubscribe, 4 | SubscribeCallOptions, 5 | } from '../../../index'; 6 | 7 | export interface IPubsubClient { 8 | publish( 9 | cacheName: string, 10 | topicName: string, 11 | value: string | Uint8Array 12 | ): Promise; 13 | subscribe( 14 | cacheName: string, 15 | topicName: string, 16 | options: SubscribeCallOptions 17 | ): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/pubsub/IWebhookClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | ListWebhooks, 3 | PutWebhook, 4 | DeleteWebhook, 5 | Webhook, 6 | WebhookId, 7 | GetWebhookSecret, 8 | RotateWebhookSecret, 9 | } from '../../../index'; 10 | 11 | export interface IWebhookClient { 12 | listWebhooks(cache: string): Promise; 13 | putWebhook(webhook: Webhook): Promise; 14 | deleteWebhook(id: WebhookId): Promise; 15 | getWebhookSecret(id: WebhookId): Promise; 16 | rotateWebhookSecret(id: WebhookId): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/pubsub/index.ts: -------------------------------------------------------------------------------- 1 | export * from '../../../clients/ITopicClient'; 2 | export * from './IPubsubClient'; 3 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/storage/IStorageControlClient.ts: -------------------------------------------------------------------------------- 1 | import {CreateStore, DeleteStore, ListStores} from '../../../index'; 2 | 3 | export interface IStorageControlClient { 4 | createStore(storeName: string): Promise; 5 | deleteStore(storeName: string): Promise; 6 | listStores(): Promise; 7 | close(): void; 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/storage/IStorageDataClient.ts: -------------------------------------------------------------------------------- 1 | import {StorageGet, StoragePut, StorageDelete} from '../../../index'; 2 | 3 | export interface IStorageDataClient { 4 | get(storeName: string, key: string): Promise; 5 | putInt( 6 | storeName: string, 7 | key: string, 8 | value: number 9 | ): Promise; 10 | putDouble( 11 | storeName: string, 12 | key: string, 13 | value: number 14 | ): Promise; 15 | putString( 16 | storeName: string, 17 | key: string, 18 | value: string 19 | ): Promise; 20 | putBytes( 21 | storeName: string, 22 | key: string, 23 | value: Uint8Array 24 | ): Promise; 25 | delete(storeName: string, key: string): Promise; 26 | close(): void; 27 | } 28 | -------------------------------------------------------------------------------- /packages/core/src/internal/clients/storage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './AbstractStorageClient'; 2 | export * from './IStorageControlClient'; 3 | export * from './IStorageDataClient'; 4 | export * from '../../../clients/IStorageClient'; 5 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/collections.ts: -------------------------------------------------------------------------------- 1 | export function range(n: number): Array { 2 | return [...Array(n).keys()]; 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/display.ts: -------------------------------------------------------------------------------- 1 | // Utility functions related to displaying things to the user. 2 | 3 | export function truncateString(value: string, maxLength = 32) { 4 | if (value.length > maxLength) { 5 | return value.substring(0, maxLength) + '...'; 6 | } else { 7 | return value; 8 | } 9 | } 10 | 11 | const DISPLAY_SIZE_LIMIT = 5; 12 | 13 | function truncateStringArrayToSize( 14 | stringArray: string[], 15 | length: number 16 | ): string[] { 17 | if (stringArray.length <= length) { 18 | return stringArray; 19 | } else { 20 | return stringArray.slice(0, length).concat(['...']); 21 | } 22 | } 23 | 24 | export function truncateStringArray( 25 | stringArray: string[], 26 | length: number = DISPLAY_SIZE_LIMIT 27 | ): string[] { 28 | const truncatedStringArray = truncateStringArrayToSize(stringArray, length); 29 | return truncatedStringArray.map(s => { 30 | return truncateString(s); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './auth'; 2 | export * from './collections'; 3 | export * from './display'; 4 | export * from './object'; 5 | export * from './sleep'; 6 | export * from './string'; 7 | export * from './validators'; 8 | export * from './semaphore'; 9 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/object.ts: -------------------------------------------------------------------------------- 1 | export function fromEntries(entries: [string, unknown][]): object { 2 | return entries.reduce((acc, [key, value]) => ({...acc, [key]: value}), {}); 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/sleep.ts: -------------------------------------------------------------------------------- 1 | export const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); 2 | -------------------------------------------------------------------------------- /packages/core/src/internal/utils/string.ts: -------------------------------------------------------------------------------- 1 | import {Buffer} from 'buffer'; 2 | 3 | export const decodeFromBase64 = (base64: string) => { 4 | return Buffer.from(base64, 'base64').toString('utf8'); 5 | }; 6 | 7 | export const encodeToBase64 = (str: string) => { 8 | return Buffer.from(str, 'utf-8').toString('base64'); 9 | }; 10 | -------------------------------------------------------------------------------- /packages/core/src/messages/cache-info.ts: -------------------------------------------------------------------------------- 1 | export interface CacheLimits { 2 | maxTrafficRate: number; 3 | maxThroughputKbps: number; 4 | maxItemSizeKb: number; 5 | maxTtlSeconds: number; 6 | } 7 | 8 | export interface TopicLimits { 9 | maxPublishRate: number; 10 | maxSubscriptionCount: number; 11 | maxPublishMessageSizeKb: number; 12 | } 13 | 14 | export class CacheInfo { 15 | private readonly name: string; 16 | private readonly topicLimits: TopicLimits; 17 | private readonly cacheLimits: CacheLimits; 18 | 19 | constructor( 20 | name: string, 21 | topicLimits: TopicLimits, 22 | cacheLimits: CacheLimits 23 | ) { 24 | this.name = name; 25 | this.topicLimits = topicLimits; 26 | this.cacheLimits = cacheLimits; 27 | } 28 | 29 | public getName() { 30 | return this.name; 31 | } 32 | 33 | public getTopicLimits() { 34 | return this.topicLimits; 35 | } 36 | 37 | public getCacheLimits() { 38 | return this.cacheLimits; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/auth/generate-api-key.ts: -------------------------------------------------------------------------------- 1 | export enum GenerateApiKeyResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/auth/generate-disposable-token.ts: -------------------------------------------------------------------------------- 1 | export enum GenerateDisposableTokenResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/auth/index.ts: -------------------------------------------------------------------------------- 1 | export {GenerateApiKeyResponse} from './generate-api-key'; 2 | export {GenerateDisposableTokenResponse} from './generate-disposable-token'; 3 | export {RefreshApiKeyResponse} from './refresh-api-key'; 4 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/auth/refresh-api-key.ts: -------------------------------------------------------------------------------- 1 | export enum RefreshApiKeyResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/cache/control/index.ts: -------------------------------------------------------------------------------- 1 | export enum CreateCacheResponse { 2 | Success = 'Success', 3 | AlreadyExists = 'AlreadyExists', 4 | Error = 'Error', 5 | } 6 | 7 | export enum DeleteCacheResponse { 8 | Success = 'Success', 9 | Error = 'Error', 10 | } 11 | 12 | export enum FlushCacheResponse { 13 | Success = 'Success', 14 | Error = 'Error', 15 | } 16 | 17 | export enum ListCachesResponse { 18 | Success = 'Success', 19 | Error = 'Error', 20 | } 21 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/cache/index.ts: -------------------------------------------------------------------------------- 1 | export * from './dictionary'; 2 | export * from './scalar'; 3 | export * from './set'; 4 | export * from './list'; 5 | export * from './sorted-set'; 6 | export * from './control'; 7 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/index.ts: -------------------------------------------------------------------------------- 1 | export * from './auth'; 2 | export * from './cache'; 3 | export * from './topics'; 4 | export * from './leaderboard'; 5 | export * from './store'; 6 | export * from './webhook'; 7 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/leaderboard/index.ts: -------------------------------------------------------------------------------- 1 | export enum LeaderboardDeleteResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | 6 | export enum LeaderboardFetchResponse { 7 | Success = 'Success', 8 | Error = 'Error', 9 | } 10 | 11 | export enum LeaderboardLengthResponse { 12 | Success = 'Success', 13 | Error = 'Error', 14 | } 15 | 16 | export enum LeaderboardRemoveElementsResponse { 17 | Success = 'Success', 18 | Error = 'Error', 19 | } 20 | 21 | export enum LeaderboardUpsertResponse { 22 | Success = 'Success', 23 | Error = 'Error', 24 | } 25 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/store/control/index.ts: -------------------------------------------------------------------------------- 1 | export enum CreateStoreResponse { 2 | Success = 'Success', 3 | AlreadyExists = 'AlreadyExists', 4 | Error = 'Error', 5 | } 6 | 7 | export enum ListStoresResponse { 8 | Success = 'Success', 9 | Error = 'Error', 10 | } 11 | 12 | export enum DeleteStoreResponse { 13 | Success = 'Success', 14 | Error = 'Error', 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/store/index.ts: -------------------------------------------------------------------------------- 1 | export * from './control'; 2 | export * from './scalar'; 3 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/store/scalar/index.ts: -------------------------------------------------------------------------------- 1 | export enum StorageGetResponse { 2 | Found = 'Found', 3 | NotFound = 'NotFound', 4 | Error = 'Error', 5 | } 6 | 7 | export enum StoragePutResponse { 8 | Success = 'Success', 9 | Error = 'Error', 10 | } 11 | 12 | export enum StorageDeleteResponse { 13 | Success = 'Success', 14 | Error = 'Error', 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/topics/index.ts: -------------------------------------------------------------------------------- 1 | export enum TopicPublishResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | 6 | export enum TopicSubscribeResponse { 7 | Subscription = 'Subscription', 8 | Error = 'Error', 9 | } 10 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/enums/webhook/index.ts: -------------------------------------------------------------------------------- 1 | export enum PutWebhookResponse { 2 | Success = 'Success', 3 | Error = 'Error', 4 | } 5 | 6 | export enum DeleteWebhookResponse { 7 | Success = 'Success', 8 | Error = 'Error', 9 | } 10 | 11 | export enum RotateWebhookSecretResponse { 12 | Success = 'Success', 13 | Error = 'Error', 14 | } 15 | 16 | export enum GetWebhookSecretResponse { 17 | Success = 'Success', 18 | Error = 'Error', 19 | } 20 | 21 | export enum ListWebhooksResponse { 22 | Success = 'Success', 23 | Error = 'Error', 24 | } 25 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/leaderboard/index.ts: -------------------------------------------------------------------------------- 1 | export * as LeaderboardDelete from './leaderboard-delete'; 2 | export * as LeaderboardFetch from './leaderboard-fetch'; 3 | export * as LeaderboardLength from './leaderboard-length'; 4 | export * as LeaderboardRemoveElements from './leaderboard-remove-elements'; 5 | export * as LeaderboardUpsert from './leaderboard-upsert'; 6 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/storage/control/index.ts: -------------------------------------------------------------------------------- 1 | export * as DeleteStore from './delete-store'; 2 | export * as CreateStore from './create-store'; 3 | export * as ListStores from './list-stores'; 4 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/storage/index.ts: -------------------------------------------------------------------------------- 1 | export * from './control'; 2 | export * from './scalar'; 3 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/storage/scalar/index.ts: -------------------------------------------------------------------------------- 1 | export * as StorageDelete from './storage-delete'; 2 | export * as StorageGet from './storage-get'; 3 | export * as StoragePut from './storage-put'; 4 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/topic-heartbeat.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a heartbeat received from a topic subscription indicating the connection is alive. 3 | * 4 | * @remarks A subscription is created by calling {@link TopicClient.subscribe}. 5 | */ 6 | export class TopicHeartbeat { 7 | public toString(): string { 8 | return `${this.constructor.name}`; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/src/messages/responses/webhook/index.ts: -------------------------------------------------------------------------------- 1 | export * as DeleteWebhook from './delete-webhook'; 2 | export * as ListWebhooks from './list-webhooks'; 3 | export * as PutWebhook from './put-webhook'; 4 | export * as GetWebhookSecret from './get-webhook-secret'; 5 | export * as RotateWebhookSecret from './rotate-webhook-secret'; 6 | -------------------------------------------------------------------------------- /packages/core/src/messages/signing-key.ts: -------------------------------------------------------------------------------- 1 | export class SigningKey { 2 | private readonly keyId: string; 3 | private readonly expiresAt: Date; 4 | private readonly endpoint: string; 5 | 6 | constructor(keyId: string, expiresAt: Date, endpoint: string) { 7 | this.keyId = keyId; 8 | this.expiresAt = expiresAt; 9 | this.endpoint = endpoint; 10 | } 11 | 12 | public getKeyId() { 13 | return this.keyId; 14 | } 15 | 16 | public getExpiresAt() { 17 | return this.expiresAt; 18 | } 19 | 20 | public getEndpoint() { 21 | return this.endpoint; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/src/messages/store-info.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * StoreInfo is a class that holds the name of the store. 3 | */ 4 | export class StoreInfo { 5 | private readonly name: string; 6 | 7 | /** 8 | * Creates an instance of the StoreInfo class. 9 | * @param {string} name - The name of the store. 10 | */ 11 | constructor(name: string) { 12 | this.name = name; 13 | } 14 | 15 | /** 16 | * Retrieves the name of the store. 17 | * @returns {string} - The name of the store. 18 | */ 19 | public getName(): string { 20 | return this.name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/core/src/messages/webhook.ts: -------------------------------------------------------------------------------- 1 | import {WebhookDestination} from '../utils'; 2 | 3 | export interface WebhookId { 4 | cacheName: string; 5 | webhookName: string; 6 | } 7 | 8 | export interface Webhook { 9 | destination: WebhookDestination; 10 | id: WebhookId; 11 | topicName: string; 12 | } 13 | -------------------------------------------------------------------------------- /packages/core/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './cache-call-options'; 2 | export * from './collection-ttl'; 3 | export * from './topic-call-options'; 4 | export * from './expiration'; 5 | export * from './itemType'; 6 | export * from './webhook-destination'; 7 | export * from './set-batch-item'; 8 | export * from './time'; 9 | -------------------------------------------------------------------------------- /packages/core/src/utils/itemType.ts: -------------------------------------------------------------------------------- 1 | export enum ItemType { 2 | SCALAR = 0, 3 | DICTIONARY = 1, 4 | LIST = 2, 5 | SET = 3, 6 | SORTED_SET = 4, 7 | } 8 | -------------------------------------------------------------------------------- /packages/core/src/utils/set-batch-item.ts: -------------------------------------------------------------------------------- 1 | export type SetBatchItem = { 2 | key: string | Uint8Array; 3 | value: string | Uint8Array; 4 | ttl?: number; 5 | }; 6 | -------------------------------------------------------------------------------- /packages/core/src/utils/time.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Converts seconds to milliseconds. 3 | * @param seconds - The number of seconds to convert. 4 | * @returns The equivalent number of milliseconds. 5 | */ 6 | export function secondsToMilliseconds(seconds: number): number { 7 | return seconds * 1000; 8 | } 9 | -------------------------------------------------------------------------------- /packages/core/src/utils/webhook-call-options.ts: -------------------------------------------------------------------------------- 1 | import {WebhookDestination} from '..'; 2 | 3 | /** 4 | * Options for the put webhook call 5 | */ 6 | export interface PutWebhookCallOptions { 7 | /** 8 | * The destination of the webhook which will be invoked 9 | */ 10 | destination: WebhookDestination | string; 11 | 12 | /** 13 | * The name of the topic for the webhook to listen too 14 | */ 15 | topicName: string; 16 | } 17 | -------------------------------------------------------------------------------- /packages/core/src/utils/webhook-destination.ts: -------------------------------------------------------------------------------- 1 | export enum WebhookDestinationType { 2 | PostUrl = 'post_url', 3 | } 4 | 5 | interface IPostUrlWebhookDestination { 6 | url: () => string; 7 | type: WebhookDestinationType.PostUrl; 8 | getType: () => WebhookDestinationType.PostUrl; 9 | } 10 | 11 | export class PostUrlWebhookDestination implements IPostUrlWebhookDestination { 12 | readonly _url: string; 13 | constructor(url: string) { 14 | this._url = url; 15 | } 16 | 17 | public url(): string { 18 | return this._url; 19 | } 20 | 21 | type: WebhookDestinationType.PostUrl; 22 | 23 | getType(): WebhookDestinationType.PostUrl { 24 | return WebhookDestinationType.PostUrl; 25 | } 26 | } 27 | 28 | export type WebhookDestination = InstanceType; 29 | -------------------------------------------------------------------------------- /packages/core/test/unit/cache-get.test.ts: -------------------------------------------------------------------------------- 1 | import * as CacheGet from '../../src/messages/responses/cache-get'; 2 | import {TextEncoder} from 'util'; 3 | 4 | const TEXT_ENCODER = new TextEncoder(); 5 | 6 | describe('CacheGet', () => { 7 | describe('#toString()', () => { 8 | it('shows a short value', () => { 9 | const value = 'Napoleon'; 10 | const hit = new CacheGet.Hit(TEXT_ENCODER.encode(value)); 11 | 12 | expect(hit.toString()).toEqual(`Hit: ${value}`); 13 | }); 14 | 15 | it('shows truncates long value', () => { 16 | const value = 'Pneumonoultramicroscopicsilicovolcanoconiosis'; 17 | const truncatedValue = 'Pneumonoultramicroscopicsilicovo...'; 18 | const hit = new CacheGet.Hit(TEXT_ENCODER.encode(value)); 19 | 20 | expect(hit.toString()).toEqual(`Hit: ${truncatedValue}`); 21 | }); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/core/test/unit/cache-list-push-front.test.ts: -------------------------------------------------------------------------------- 1 | import {CacheListPushFront} from '../../src'; 2 | 3 | describe('CacheListPushFront', () => { 4 | describe('#toString', () => { 5 | it('shows the list length', () => { 6 | const length = 23; 7 | const push = new CacheListPushFront.Success(length); 8 | 9 | expect(push.toString()).toEqual(`Success: listLength: ${length}`); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/core/test/unit/messages/get-response.test.ts: -------------------------------------------------------------------------------- 1 | import {TextEncoder} from 'util'; 2 | import {CacheGet} from '../../../src'; 3 | 4 | describe('get-response.ts', () => { 5 | it('should correctly instantiate a GetResponse object', () => { 6 | const byteArray = new Uint8Array(12); 7 | const getResponse = new CacheGet.Hit(byteArray); 8 | expect(getResponse.valueUint8Array()).toBe(byteArray); 9 | }); 10 | it('should correctly convert string text from byte array', () => { 11 | const testString = 'this is a test'; 12 | const textEncoder = new TextEncoder(); 13 | const getResponse = new CacheGet.Hit(textEncoder.encode(testString)); 14 | expect(getResponse.valueString()).toEqual(testString); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /scripts/build-all-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building all packages" 9 | 10 | ${ROOT_DIR}/scripts/build-package.sh "core" 11 | ${ROOT_DIR}/scripts/build-package.sh "common-integration-tests" 12 | ${ROOT_DIR}/scripts/build-package.sh "client-sdk-nodejs" 13 | ${ROOT_DIR}/scripts/build-package.sh "client-sdk-nodejs-compression" 14 | ${ROOT_DIR}/scripts/build-package.sh "client-sdk-nodejs-compression-zstd" 15 | ${ROOT_DIR}/scripts/build-package.sh "client-sdk-web" 16 | -------------------------------------------------------------------------------- /scripts/build-and-test-all-packages-consistent-reads.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building and testing JS SDK with consistent reads" 9 | 10 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "core" 11 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "common-integration-tests" 12 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "client-sdk-nodejs" 13 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "client-sdk-nodejs-compression" 14 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "client-sdk-nodejs-compression-zstd" 15 | ${ROOT_DIR}/scripts/build-and-test-package-consistent-reads.sh "client-sdk-web" 16 | -------------------------------------------------------------------------------- /scripts/build-and-test-all-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "dev building web sdk" 9 | 10 | ${ROOT_DIR}/scripts/build-and-test-package.sh "core" 11 | ${ROOT_DIR}/scripts/build-and-test-package.sh "common-integration-tests" 12 | ${ROOT_DIR}/scripts/build-and-test-package.sh "client-sdk-nodejs" 13 | ${ROOT_DIR}/scripts/build-and-test-package.sh "client-sdk-nodejs-compression" 14 | ${ROOT_DIR}/scripts/build-and-test-package.sh "client-sdk-nodejs-compression-zstd" 15 | ${ROOT_DIR}/scripts/build-and-test-package.sh "client-sdk-web" 16 | -------------------------------------------------------------------------------- /scripts/build-and-test-package-consistent-reads.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building and testing package: ${1}" 9 | 10 | ${ROOT_DIR}/scripts/build-package.sh ${1} 11 | 12 | pushd ${ROOT_DIR}/packages/${1} 13 | npm run unit-test 14 | npm run integration-test-consistent-reads 15 | popd 16 | -------------------------------------------------------------------------------- /scripts/build-and-test-package-retry-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building and testing JS SDK with full network outage" 9 | 10 | ${ROOT_DIR}/scripts/build-package.sh "core" 11 | ${ROOT_DIR}/scripts/build-package.sh "common-integration-tests" 12 | ${ROOT_DIR}/scripts/build-package.sh "client-sdk-nodejs" 13 | 14 | echo "building and testing automated retries" 15 | 16 | pushd ${ROOT_DIR}/packages/client-sdk-nodejs 17 | npm run integration-test-retry 18 | popd 19 | -------------------------------------------------------------------------------- /scripts/build-and-test-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building and testing package: ${1}" 9 | 10 | ${ROOT_DIR}/scripts/build-package.sh ${1} 11 | 12 | pushd ${ROOT_DIR}/packages/${1} 13 | npm run unit-test 14 | npm run integration-test 15 | popd 16 | -------------------------------------------------------------------------------- /scripts/build-nodejs-sdk-for-lambda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | echo "dev building nodejs sdk for aws lambda" 7 | 8 | ./scripts/build-package-lambda.sh "common-integration-tests" 9 | ./scripts/build-package-lambda.sh "client-sdk-nodejs" 10 | -------------------------------------------------------------------------------- /scripts/build-nodejs-sdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | echo "dev building nodejs sdk" 7 | 8 | ./scripts/build-package.sh "core" 9 | ./scripts/build-package.sh "common-integration-tests" 10 | ./scripts/build-package.sh "client-sdk-nodejs" 11 | ./scripts/build-package.sh "client-sdk-nodejs-compression" 12 | ./scripts/build-package.sh "client-sdk-nodejs-compression-zstd" 13 | -------------------------------------------------------------------------------- /scripts/build-package-lambda.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building package: ${1}" 9 | 10 | pushd ${ROOT_DIR}/packages/${1} 11 | npm ci 12 | npm run format 13 | npm run build-without-local-core 14 | npm run lint 15 | popd 16 | -------------------------------------------------------------------------------- /scripts/build-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "building package: ${1}" 9 | 10 | pushd ${ROOT_DIR}/packages/${1} 11 | npm ci 12 | npm run build 13 | npm run lint 14 | popd 15 | -------------------------------------------------------------------------------- /scripts/build-web-sdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | echo "dev building web sdk" 7 | 8 | ./scripts/build-package.sh "core" 9 | ./scripts/build-package.sh "common-integration-tests" 10 | ./scripts/build-package.sh "client-sdk-web" 11 | -------------------------------------------------------------------------------- /scripts/make-localhost-token-from-dev-token.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -x 5 | 6 | DEV_TOKEN=$1 7 | if [ "$DEV_TOKEN" == "" ] 8 | then 9 | echo "Missing required argument: dev token" 10 | echo "Usage: $0 " 11 | exit 1 12 | fi 13 | 14 | echo "{\"endpoint\":\"localhost\",\"api_key\":\"${DEV_TOKEN}\"}" |base64 15 | -------------------------------------------------------------------------------- /scripts/publish-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | usage() { 7 | echo "Usage: $0 " 8 | } 9 | 10 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 11 | 12 | PACKAGE=${1} 13 | if [ "${PACKAGE}" == "" ] 14 | then 15 | echo "Missing required argument: PACKAGE" 16 | usage 17 | exit 1 18 | fi 19 | 20 | VERSION=${2} 21 | if [ "${VERSION}" == "" ] 22 | then 23 | echo "Missing required argument: VERSION" 24 | usage 25 | exit 1 26 | fi 27 | 28 | CORE_VERSION=${3} 29 | if [ "${CORE_VERSION}" == "" ] 30 | then 31 | echo "Missing required argument: CORE_VERSION" 32 | usage 33 | exit 1 34 | fi 35 | 36 | ${ROOT_DIR}/scripts/update-package-versions.sh ${PACKAGE} ${VERSION} ${CORE_VERSION} 37 | 38 | echo "publishing package: ${PACKAGE} with version ${VERSION} (core version: ${CORE_VERSION})" 39 | 40 | pushd ${ROOT_DIR}/packages/${PACKAGE} 41 | npm publish --access public 42 | popd 43 | -------------------------------------------------------------------------------- /scripts/test-auth-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "running auth testing" 9 | 10 | pushd ${ROOT_DIR}/packages/client-sdk-web 11 | npm run integration-test-auth 12 | popd 13 | 14 | pushd ${ROOT_DIR}/packages/client-sdk-nodejs 15 | npm run integration-test-auth 16 | popd 17 | -------------------------------------------------------------------------------- /scripts/test-leaderboard-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "running leaderboard tests" 9 | 10 | pushd ${ROOT_DIR}/packages/client-sdk-web 11 | npm run integration-test-leaderboard 12 | popd 13 | 14 | pushd ${ROOT_DIR}/packages/client-sdk-nodejs 15 | npm run integration-test-leaderboard 16 | popd 17 | -------------------------------------------------------------------------------- /scripts/test-store-packages.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | ROOT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd ) 7 | 8 | echo "running storage tests" 9 | 10 | pushd ${ROOT_DIR}/packages/client-sdk-web 11 | npm run integration-test-store 12 | popd 13 | 14 | pushd ${ROOT_DIR}/packages/client-sdk-nodejs 15 | npm run integration-test-store 16 | popd 17 | --------------------------------------------------------------------------------