Awesome Open Source
Awesome Open Source

TypeScript REST Node Starter

This repository can be used as a convenient starting point for building NODE REST API's using TypeScript on top of Express web framework.


  • Basic JWT authentication and account activation using SMTP
  • Repository pattern used to enable separation of concerns
  • MongoDB - default repository implementation, should be easy to replace


  • Install Node.js
  • Install MongoDB
  • Configure your SMTP service and enter your SMTP settings inside .env.example

Getting started

  • Clone the repository
git clone --depth=1 <project_name>
  • Install dependencies
cd <project_name>
npm install
  • Configure your mongoDB server
# create the db directory
sudo mkdir -p /data/db
# give the db correct read/write permissions
sudo chmod 777 /data/db
  • Start your mongoDB server (you'll probably want another command prompt)
  • Build and run the project
npm run build
npm start


To access Swagger UI for available endpoints


Pass token from /auth/login when using protected endpoints (for example: getting all /users) like Bearer <token>

REST endpoints

  • public: /auth/login, /auth/register, /auth/activate
  • protected: /users


  • Register
curl -d '{"email":"[email protected]", "password":"PASSWORD", "lname": "Doe", "fname": "John", "role": "guest", "username": "jdoe"}' -H "Content-Type: application/json" -X POST http://localhost:3000/auth/register
  • Activation
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://localhost:3000/auth/activate/ACTIVATION_TOKEN
  • Login
curl -i -d '{"email":"[email protected]", "password":"PASSWORD"}' -H "Content-Type: application/json" -X POST http://localhost:3000/auth/login
  • GET /users
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer JWT_TOKEN_HERE" -X GET http://localhost:3000/users/

Import mock users

mongoimport --db heroes-db --collection users --file users.json --jsonArray


  • Before running tests be sure to create a real .env file in root using the fields found in .env.example
npm run test


  • Implement RBAC functionality
  • Integrate Swagger
  • Test coverage


The repository is based on Microsoft/TypeScript-Node-Starter

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Typescript (252,937
Node (12,583
Rest (4,066
Jest (3,557
Jwt (3,556
Swagger (2,629
Mongo (880
Related Projects