https://github.com/v-checha/aws-lambda-dynamodb-serverless-starter
It is a serverless application that uses AWS lambda, dynamodb, and api gateway. It is written in typescript and uses the serverless framework.
https://github.com/v-checha/aws-lambda-dynamodb-serverless-starter
api-gateway dynamodb dynamodb-admin dynamodb-offline lambda middify serverless serverless-offline
Last synced: 6 months ago
JSON representation
It is a serverless application that uses AWS lambda, dynamodb, and api gateway. It is written in typescript and uses the serverless framework.
- Host: GitHub
- URL: https://github.com/v-checha/aws-lambda-dynamodb-serverless-starter
- Owner: v-checha
- Created: 2024-02-06T08:59:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T15:41:26.000Z (almost 2 years ago)
- Last Synced: 2025-04-24T04:51:29.250Z (11 months ago)
- Topics: api-gateway, dynamodb, dynamodb-admin, dynamodb-offline, lambda, middify, serverless, serverless-offline
- Language: TypeScript
- Homepage: https://www.nodeteam.onix-systems.com/
- Size: 115 KB
- Stars: 29
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
It is a serverless application that uses AWS lambda, dynamodb, and api gateway. It is written in typescript and uses the serverless framework.
# Setup
## Prerequisites
- nodejs
- npm
- serverless framework
- aws cli
- aws credentials
- dynamodb local
- dynamodb admin
- dynamodb migrate
- Java Runtime Engine (JRE) version 6.x or newer
# Features
- 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](https://aws.amazon.com/ses/)
## Installation
Setup npm dependencies
```bash
npm install
```
Setup serverless framework
```bash
npm install -g serverless
```
Install dynamodb local
DynamoDb Oflline Plugin Requires:
- serverless@^1
- Java Runtime Engine (JRE) version 6.x or newer
```bash
npx sls dynamodb install
```
Install dynamodb admin
```bash
npm install -g dynamodb-admin
```
after installation, run the following command to start dynamodb admin
```bash
dynamodb-admin
```
_note: admin will be available at http://localhost:8001
Install dynamodb migrate
```bash
npm install -g dynamodb-migrate
```
## Run
```bash
npx serverless offline start --stage=dev
```
## Deploy
```bash
npx serverless deploy --stage=
```
## Remove
```bash
npx serverless remove --stage=
```
# API Documentation
Will be available at http://localhost:3000/swagger
# Project Structure
```bash
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:
```typescript
const create = middyfy(
{
type: 'object',
required: ['body'],
properties: {
body: {
type: 'object',
required: ['email'],
properties: {
email: { type: 'string', format: 'email' },
},
},
},
},
async (event: APIGatewayProxyEventWithBody): Promise => {
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.
# Contributing Guide
## Branching
- `master` - production branch
- `dev` - development branch
- `feature/` - feature branch
- `bugfix/` - bugfix branch
- `hotfix/` - hotfix branch
- `release/` - release branch
- `docs/` - documentation branch
- `test/` - test branch
- `chore/` - chore branch
- `refactor/` - refactor branch
- `style/` - style branch
- `ci/` - ci branch
## Commit Message
```bash
[optional scope]:
```
Example:
```bash
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.