non-fungible-apps/serverless
Janison Sivarajah 9e202f0a1f
feat: sc 121 - serverless boilerplate (#140)
* chore: init for redoing aws stack base

* chore: fix tsc build errors

* chore: remove comment, remove schema verif that was causing error, add context

* chore: replace serverless.ts with serverless.yaml

* chore: rename serverless file correctly

* chore: fix deployment errors

* chore: add serverless-offline

* chore: fix bug executing function

* chore: readme for aws

* chore: rename to kebab-case and add eslint rule for it

* chore: add aws cred link to serverless readme
2023-04-04 14:42:51 -04:00
..
src feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
.gitignore feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
README.md feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
package.json feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
serverless.yaml feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
tsconfig.json feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00
yarn.lock feat: sc 121 - serverless boilerplate (#140) 2023-04-04 14:42:51 -04:00

README.md

NFA - Serverless

Requirements

This sub-project of NFAs requires Node 18. Specifically, this has been tested with 18.13.0 so far.

Setup

After cloning the repo, ensure you run yarn in the root directory. After that, cd into the serverless directory and alsy run yarn.

If you are deploying, make sure you have your AWS credentials set to environment variables or have setup AWS credentials using the AWS CLI. Please refer to the official AWS documentation here to see all the ways to set these credentials.

Basically, these values need to be set:

export AWS_ACCESS_KEY_ID=value
export AWS_SECRET_ACCESS_KEY=value
export AWS_SESSION_TOKEN=value

You can get these from the main screen after logging in.

Running and Testing

You first build the code by running yarn build. This will produce the bundle file in the dist directory.

TODO: yarn test

To run locally, use SLS_DEBUG=* yarn sls offline --verbose. You can then hit the endpoints displayed in the console using curl, postman or any HTTP client.

Deploying

To deploy, make sure you have AWS credentials set in your local environment.

To deploy to development environment: yarn sls deploy --stage dev

To deploy to production environment: yarn sls deploy --stage prd