Skip to content

A boilerplate for creating production-ready API using Express, Typescript, MongoDB and Jest

Notifications You must be signed in to change notification settings

miladr0/express-typescript-mongodb

Repository files navigation

🎫 A Class Base Routing Boilerplate for Node.js, Express.js, MongoDB with Typescript.

What is it?

Try to implement A Class Base Routing with clean structure and scalable boilerplate in Node.js,Express.js and Typescript.

Features


Getting Started

install dependencies

yarn

Without Docker

Note: It is assumed here that you have MongoDB running in the background.

set .env.development.local file with your credentials.(like DB URL)

Run the app

yarn dev

With Docker

Note: It is assumed here that you have installed Docker and running in the background.

yarn docker:db

set .env.development.local file with your credentials.(like DB URL)

Run the app

yarn dev


Route Documents

you can access swagger documentation at http://localhost:3000/api-docs




What is the Structure of template?

express-typescript-boilerplate
├─ .github
│  └─ workflows
│     └─ tests.yml
├─ README.md
├─ ecosystem.config.js
├─ jest.config.js
├─ package.json
├─ src
│  ├─ __tests__
│  │  ├─ api
│  │  │  └─ v1
│  │  │     └─ auth
│  │  │     └─ users
│  ├─ api
│  │  └─ v1
│  │     ├─ auth
│  │     │  ├─ auth.controller.ts
│  │     │  └─ dtos
│  │     ├─ index.ts
│  │     └─ user
│  │        └─ user.controller.ts
│  ├─ app.ts
│  ├─ common
│  │  ├─ constants
│  │  │  └─ index.ts
│  │  ├─ interfaces
│  │  │  ├─ crud.interface.ts
│  │  │  └─ timestamp.interface.ts
│  │  └─ types
│  ├─ config
│  │  ├─ index.ts
│  │  └─ passport.ts
│  ├─ exceptions
│  │  └─ HttpException.ts
│  ├─ index.ts
│  ├─ middlewares
│  │  ├─ auth.middleware.ts
│  │  ├─ handlingErrors.middleware.ts
│  │  └─ validation.middleware.ts
│  ├─ models
│  │  ├─ tokens.model.ts
│  │  └─ users.model.ts
│  ├─ services
│  │  └─ v1
│  │     ├─ auth.service.ts
│  │     ├─ index.ts
│  │     ├─ token.service.ts
│  │     └─ user.service.ts
│  └─ utils
│     └─ toJSON.plugin.ts
├─ tsconfig.json