Skip to content

BlackSenPig/node-express-typescript-boilerplate

Repository files navigation

node-typescript-boilerplate

TypeScript version Node.js version APLv2

👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects.

🏃🏽 Instant Value: All basic tools included and configured:

  • nodemon
  • express
  • dotenv
  • cors
  • mongoose
  • swagger
  • tsoa
  • docker
  • validator
  • helmet
  • husky
  • TypeScript 4.6
  • ESLint with some initial rules recommendation
  • Jest for fast unit testing and code coverage
  • Type definitions for Node.js and Jest
  • Prettier to enforce consistent code style
  • NPM scripts for common operations
  • Simple example of TypeScript code and unit test
  • .editorconfig for consistent file format
  • Reproducible environments thanks to Volta
  • Example configuration for GitHub Actions

🤲 Free as in speech: available under the APLv2 license.

Getting Started

This project is intended to be used with the latest Active LTS release of Node.js.

Project Structure

public              # swagger-ui-express tsoa
src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers (controller layer)
 |--models\         # Mongoose models (data layer)
 |--routes\         # Swagger tsoa routes
 |--services\       # Business logic (service layer)
 |--utils\          # Utility classes and functions
 |--validations\    # Request data validation schemas
 |--index.js        # App entry point

Available Scripts

  • start
  • dev
  • clean - remove coverage data, Jest cache and transpiled files,
  • prebuild - lint source files and tests before building,
  • build - transpile TypeScript to ES6,
  • build:watch - interactive watch mode to automatically transpile source files,
  • swagger
  • swagger route
  • lint - lint source files and tests,
  • docker:dev
  • test - run tests,
  • test:watch - interactive watch mode to automatically re-run tests

Additional Informations

License