Skip to content

thanhlq/fastify-starter-kit

Repository files navigation

Fastify & Typescript App

1. FEATURES

  • Fastify as core (Can be customized / replaced by expressjs,...)
  • Modern typescript / ESM
  • Typescript documentation with typedoc
  • DB schema migration (by versions)
  • Lightweigh ORM with objection / knex
  • Common securities (xss, rate limit, csrf, csp, header protection)
  • OpenAPI 3.0 documentation in a modular way
  • DB unit test with Jest / Typescript / ESM
  • Restful API testing with supertest
  • Static file serving.
  • Static source code analysis and checks with eslint
  • Source code auto format with prettier
  • Tested with Node.js 14+

2. Installation

$ git clone xxx
$ cd project
$ yarn install
# For development
./scripts/install-dev-dependencies.sh
./scripts/install-build-dependencies.sh

3. Usage

At first time, you need to run Database schema generation. Configure your database information at /knexfile.js, then run: yarn migrate-env accorndingly, for example:

# Generate db schemas for development
yarn migrate-dev
# Generate db schemas for testing
yarn migrate-test
# Generate db schemas for production
yarn migrate-prod

3.1 Development

# Start development server with hot reload (nodemon)
$ yarn dev

# Start development server with buit and NOT hot-reload
$ yarn start-dev

# Format with prettier
$ yarn format

# Check code lint (eslint)
$ yarn lint

# Generate class documentation (typescript docs) (docs folder by default) : currently NOK with ESM
$ yarn docs

3.2 Test

# Start test server (dont need, integrated with concurrently)
# yarn start-test

# Start to execute the tests
yarn test

3.3 Production

# build for production
$ yarn build

# start production app
$ yarn start

3.4 Docker

# Build docker image
$ scripts/build-docker-image.sh

# Start container
$ cd docker
$ docker-compose up

3.5 OPENAPI Document

To generate latest openapi (swagger) docs:

yarn build-api-docs

4 Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published