@kazize/create-ts-starter-1

1.0.1 • Public • Published

Typescript Server Boilerplate on AWS Lambda

Node.js CI

Production-ready Node.js v20 TypeScript app using MongoDB. Deployable to AWS Lambda using AWS SAM.

Compatible with Node.js >=19

This project does not use experimental flags such as --es-module-specifier-resolution or any custom loaders. Instead all TypeScript files have .js extensions in their import statements.

Table of Contents

Features

  • ES2020: transpiles to ES2020 modules
  • Static Typing: TypeScript static typing using typescript
  • Hot Reloading: Concurrently Hot realoding with concurrently
  • NoSQL database: MongoDB object data modeling using Mongoose
  • Authentication and authorization: using passport
  • Validation: request data validation using Joi
  • Logging: using winston and morgan
  • Testing: unit and integration tests using Jest
  • Error handling: centralized error handling mechanism
  • API documentation: with swagger-jsdoc and swagger-ui-express
  • Dependency management: with Yarn
  • Environment variables: using dotenv and cross-env and AWS Secrets Manager
  • Security: set security HTTP headers using helmet
  • Santizing: sanitize request data against xss and query injection
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Compression: gzip compression with compression
  • AWS Lambda: IaC with AWS SAM
  • CI: continuous integration with GitHub CI
  • Git hooks: with husky and lint-staged
  • Linting: with ESLint and Prettier
  • Editor config: consistent editor configuration using EditorConfig
  • Structured Commit Messages: with Commitizen
  • Commit Linting: with CommitLint

Quick start

To clone this project, run:

npx @kazize/create-ts-starter-1

Or,

npm init @kazize/ts-starter-1

Manual Installation

Clone the repo.

Install the dependencies:

yarn install

Set the environment variables:

cp .env.example .env

Open .env and modify the environment variables (if needed).

Make sure you have MongoDB running. Then:

yarn dev

AWS Lambda Deployment

Make sure you have AWS and SAM CLIs installed locally.

Make sure you have MongoDB running on a cloud.

(Optional) Update the following in config object in package.json if necessary.

  • s3BucketName
  • region
  • cloudFormationStackName

Create AWS Secrets Manager secrets like so:

  • ts-starter-1/prod/JWT:secret
  • ts-starter-1/prod/MONGODB_URL:url

If you change the prefix in the secrets above from ts-starter-1 to something else, then update sam-template.yaml as well.

Finally, run the following. Warning, this will create an S3 bucket and a CloudFormation Stack on your configured AWS account.

yarn setup

Inspirations

License

MIT

Package Sidebar

Install

npm i @kazize/create-ts-starter-1

Weekly Downloads

24

Version

1.0.1

License

MIT

Unpacked Size

15.1 kB

Total Files

4

Last publish

Collaborators

  • kazizehsan