Code Monkey home page Code Monkey logo

rest-api-node-ts-boilerplate's Introduction

RESTful API using Node.js, Express, Mongoose & TypeScript

technologies

This is a boilerplate for building scalable and robust REST APIs using Node.js & TypeScript.

Table of Contents

Prerequisites

You need to install MongoDB either on your local machine or using a cloud service as mLab.

Features

Getting Started

Installation

  1. install the dependencies using npm install or npm i

  2. Rename the file .env.example to .env, then you need to configure the file config.ts located in src/config

  3. Start the app using npm run dev

  4. After that, go to: http://localhost:3000/v1/users

Directory Structure

├── src
│   ├── apiV1
│   │   ├── auth
│   │   │  ├── auth.controller.ts
│   │   │  └── auth.route.ts
│   │   ├── users
│   │   │   ├── user.controller.ts
│   │   │   ├── user.controller.ts
│   │   │   └── user.route.ts
│   │   └── index.ts
│   ├── config
│   │   ├── config.ts
│   │   └── db.ts
│   ├── helpers
│   │   ├── errorHandler.ts
│   │   └── verifyToken.ts
│   ├── .env.example
│   ├── App.ts
│   └── index.ts
├── .editorconfig
├── .gitignore
├── package.json
├── README.md
├── tsconfig.json
└── tslint.json

Available routes

Method Resource Description
POST /register Create a new user in the DB. You need to specify in the body the following attributes: name, lastname, email & password.
POST /authenticate Sign in with the email & password. If it's successful, then generates a token
GET /users Returns the collection of users present in the DB.
GET /users/:id It returns the specified id user. You need to specify the token in the header with the following format: Authorization: Bearer your-token
PUT /users/:id Updates an already created user in the DB
DELETE /users/:id Deletes a user from the DB

Available scripts

  • build - Transpile TypeScript to ES6,
  • lint - Lint your TS code,
  • dev - To run the app without transpile to ES6,
  • clean - Remove dist, node_modules, coverage folders,
  • start - Run the transpiled app
  • prod - Build & run the transpiled app

License

MIT © Michael Méndez

rest-api-node-ts-boilerplate's People

Contributors

alex22596 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.