rokket-labs / sst-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rokket Labs' SST Template

This project was bootstrapped with Create Serverless Stack.

Features

  • Rokket Labs code configuration
  • Serverless Stack (SST)
  • Cognito Authentication (with post confirmation handlers and custom email templates)
  • S3 Bucket configuration and permissions
  • Apollo GraphQL with Code First approach (TypeGraphQL)
  • MongoDB with Typegoose
  • RBAC Authorization examples
  • Pagination model examples
  • [] Jest test environment

Start by installing the dependencies.

$ yarn

Commands

yarn run start

Starts the local Lambda development environment.

yarn run build

Build your app and synthesize your stacks.

Generates a .build/ directory with the compiled files and a .build/cdk.out/ directory with the synthesized CloudFormation stacks.

yarn run deploy [stack]

Deploy all your stacks to AWS. Or optionally deploy a specific stack.

yarn run remove [stack]

Remove all your stacks and all of their resources from AWS. Or optionally remove a specific stack.

yarn run test

Runs your tests using Jest. Takes all the Jest CLI options.

Documentation

Notes

  • Make sure you set the app name on sst.json as this will be used to create every AWS resource name as a prefix.

  • Don't update (or add) @aws-cdk or @serverless-stack dependencies manually, as they depend on each others' versions. To update SST, always use yarn sst update <version> which will take care of all AWS CDK dependencies as well. If you need to add a new AWS CDK package, use yarn sst add-cdk @aws-cdk/<package>.

  • If you need to connect your API to a different Cognito User Pool, add the following environment variables to your setup with their respective IDs: COGNITO_USER_POOL and COGNITO_USER_POOL_CLIENT.

  • Make sure every entrypoint for your stack (every function called either by API Gateway or through an external trigger) includes import 'reflect-metadata' at the top of your file, since this app relies heavily on the use of decorators.

  • A generic class with pagination options is included on src/utils/schemas/PaginatedModel.ts. In order to use this, create a new class that extends from this model and make sure you include the docs property, which should be an array of your specific model.

  • By default, all endpoints are protected by Cognito JWT authentication. If there's a need for a public GraphQL endpoint, either create a second function which has no auth included, or move authentication to the src/utils/authChecker.ts file. Authentication is not necessary for local development, but it is enforced once functions are deployed.

  • Cognito emails (account verification, forgot password, etc.) are sent through Cognito itself, which is NOT the best idea for production environments. If you're deploying on a production environment, make sure you follow instructions on stacks/AuthStack.ts for configuring an email address and SES configuration for that specific account.

  • All entrypoint files (functions) should be set on src/functions.

  • Make sure you have AWS credentials set on your local computer. They should be on ~/.aws/credentials, under the default selector. If you have more than one profile on your computer, run export AWS_PROFILE=<your-profile-name> before running any commands on this repository.

Learn more about the Serverless Stack.

Community

Follow us on Twitter or post on our forums.

About


Languages

Language:HTML 77.1%Language:TypeScript 22.2%Language:Shell 0.5%Language:JavaScript 0.2%