Skip to content

agger34/nestjs-serverless-template

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Required

- nodejs
- jdk

Installation

$ npm install serverless -g
$ npm install

# to sync 
$ serverless plugin install -n serverless-dynamodb-local
$ serverless plugin install -n serverless-offline
$ serverless plugin install -n serverless-jetpack

# to install dynamondb
$ serverless dynamodb install

Running the app to develop

# to run dynamodb locally
$ docker-compose up -d

# to create/update .env file

# to run/debug app
$ npm run start

Running the app to test serverless

$ npm run start:serverless

Running dynamodb-admin

# to install dynamodb-admin
$ npm install -g dynamodb-admin

# to set DYNAMO_ENDPOINT
## linux
$ export DYNAMO_ENDPOINT=http://localhost:8000
## windows
$ set DYNAMO_ENDPOINT=http://localhost:8000

# to run dynamodb-admin
$ dynamodb-admin

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Deployment

TBU

Folder Structure

# 1. Overview
├───src
│   ├───database     # Database provider files, ex: mongodb, mysql
│   ├───decorator    # Decorator files, ex: @Roles
│   ├───guard        # Guard files, ex: JwtAuthGuard
│   ├───middleware   # Middleware files, ex: Logger
│   ├───module       # Source files, internal and external modules
│   │   ├───auth
│   │   ├───todo     # A sample todo modules include
│   │   └───user
│   ├───script       # Script files to run other process built with NestJs also
│   └───shared       # Enum, Constant, Helper.. to share across the system
└───test

# 2. Sample module details
.      
├───module
│   ├───todo
│   │       todo.controller.ts
│   │       todo.dto.ts
│   │       todo.enum.ts
│   │       todo.interface.ts
│   │       todo.module.ts
│   │       todo.providers.ts
│   │       todo.repository.ts
│   │       todo.schema.ts
│   │       todo.service.ts

Note

Currently, there's an issue with serverless-dynamodb-local, so I fixed temporarily dynamodb-localhost": "github:99x/dynamodb-localhost#db30898f8c40932c7177be7b2f1a81360d12876d in package. I will update it later.

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.