It is a serverless application that uses AWS lambda, dynamodb, and api gateway. It is written in typescript and uses the serverless framework.
- nodejs
- npm
- serverless framework
- aws cli
- aws credentials
- dynamodb local
- dynamodb admin
- dynamodb migrate
- Java Runtime Engine (JRE) version 6.x or newer
- User
- Create a user
- Get a user
- Update a user
- Delete a user
- Shop
- Create a shop
- Get a shop
- Mail - send an email via AWS SES
Setup npm dependencies
npm install
Setup serverless framework
npm install -g serverless
Install dynamodb local
DynamoDb Oflline Plugin Requires:
- serverless@^1
- Java Runtime Engine (JRE) version 6.x or newer
npx sls dynamodb install
Install dynamodb admin
npm install -g dynamodb-admin
after installation, run the following command to start dynamodb admin
dynamodb-admin
_note: admin will be available at http://localhost:8001
Install dynamodb migrate
npm install -g dynamodb-migrate
npx serverless offline start --stage=dev
npx serverless deploy --stage=<name>
npx serverless remove --stage=<name>
Will be available at http://localhost:3000/swagger
src ├── functions │ ├── mail │ │ ├── handler.ts │ │ └── routes.ts │ ├── shop │ │ ├── handler.ts │ │ └── routes.ts │ └── user │ ├── handler.ts │ └── routes.ts ├── libs │ ├── api-gateway.ts │ ├── handler-resolver.ts │ └── lambda.ts ├── model │ ├── Shop.ts │ ├── User.ts │ └── index.ts └── services ├── index.ts ├── shop-service.ts └── user-service.ts
Each function has its own folder with a handler and routes file. The handler file contains the lambda function and the routes file contains the api gateway routes. Example of the handler file:
const create = middyfy( { type: 'object', required: ['body'], properties: { body: { type: 'object', required: ['email'], properties: { email: { type: 'string', format: 'email' }, }, }, }, }, async (event: APIGatewayProxyEventWithBody<any>): Promise<APIGatewayProxyResult> => { const user = await userService.create({ email: event.body.email, userId: uuidv4(), isVerified: false, }); return formatJSONResponse({ user, }); }, );
middify
- is a helper function that wraps the lambda function with params validation and error handling.
master
- production branchdev
- development branchfeature/<name>
- feature branchbugfix/<name>
- bugfix branchhotfix/<name>
- hotfix branchrelease/<name>
- release branchdocs/<name>
- documentation branchtest/<name>
- test branchchore/<name>
- chore branchrefactor/<name>
- refactor branchstyle/<name>
- style branchci/<name>
- ci branch
<type>[optional scope]: <description>
Example:
feat(api): send an email to the customer when a product is shipped
Commit message should be with the next format - conventionalcommits We are use commitizen for commit message formatting.