Skip to content

Complete beginner-friendly TypeScript, Express/Node.js, MongoDB application boilerplate setup along with error logger, linters, pre-commit hooks, and unit/integration tests using jest.

License

Notifications You must be signed in to change notification settings

manjillama/node-typescript-starter

Repository files navigation

Complete TypeScript, Express/Node.js application boilerplate setup along with error logger, linters, pre-commit hooks, and unit/integration tests using jest.

PRs Welcome code style: airbnb Tested with Jest

Folder structure

|-- migrations        # Database migration dir
|-- tests             # All unit and integration test files goes here
|-- .husky            # Husky hooks for git pre-commits for lint check
|-- src
    |   index.js      # App entry point
    |   app.js        # Load express application modules
    |-- config        # Environment variables and configuration related stuff
    |-- constants     # App constants
    |-- controllers   # Express route controllers
    |-- interfaces    # TypeScript interfaces
    |-- middlewares   # Express middlewares
    |-- models        # Mongoose models
    |-- routes        # Express routes
    |-- services      # Service modules
    |-- startup       # Split the startup process into modules
    |-- types         # Shared TypeScript types
    |-- utils         # Shared utilities modules

Requirements

  • NodeJS >= 14.x
  • Yarn >= 1.x
  • MongoDB >= 5.x

Setup

First of all, you need to check if you're using the required versions of Node.js and npm

Then, please follow the instructions below:

Clone the repo:

$ git clone https://github.com/manjillama/typescript-node-boilerplate.git

$ cd typescript-node-boilerplate

Install dependencies:

$ yarn

Set environment variables:

$ cp .env.example .env

Import sample documents

$ yarn seed:import

Running Locally

$ yarn dev

Available Scripts

In the project directory, you can run:

Lint

# lint code with ESLint
$ yarn lint

# try to fix ESLint errors
$ yarn lint:fix

Test

# run all tests with Mocha
$ yarn test

Validate

# run lint and tests
$ yarn validate

Run debugger

$ yarn debug

Populate database collections with sample documents

$ yarn seed:import

Clear all database documents

$ yarn seed:delete

Contributing guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

License

Licensed under the MIT License.

About

Complete beginner-friendly TypeScript, Express/Node.js, MongoDB application boilerplate setup along with error logger, linters, pre-commit hooks, and unit/integration tests using jest.

Topics

Resources

License

Stars

Watchers

Forks