Giter Site home page Giter Site logo

rest-api-boilerplate's Introduction

REST API Boilerplate

A boilerplate for building RESTful APIs using Node.js, Express and Mongoose.

Features

  • Error Handling: centralized error handling mechanism
  • Authentication and Authorization: using JWT
  • NoSQL database: MongoDB
  • Object Data Modeling:using Mongoose
  • Validation: using Joi
  • Testing: unit tests using Jest
  • CORS: Cross-Origin Resource Sharing enabled using cors
  • API Documentation: using Swagger UI express
  • Environment Variables: using dotenv
  • Dependency Management: using npm
  • Linting: using ESLint and Prettier

Quick Start

Get started with the below steps:

  1. Clone the repo:
git clone https://github.com/shraddha319/REST-API-boilerplate.git
cd REST-API-boilerplate
  1. Install the dependencies
npm install
  1. Set the environment variables
cp .env.example .env

# modify the environment variables in .env if required

Environment Varibles

The environment variables can be found and modified in the .env file.

Commands

The following commands can be found under scripts in package.json.

Run locally:

npm run dev

Run in production:

npm run start

Testing:

# run all tests
npm run test

# run all tests in watch mode
npm run test:watch

# run test coverage
npm run test:coverage

Linting:

# run ESLint
npm run lint

# fix ESLint errors
npm run lint:fix

API Documentation

API documentation is done with the help of Swagger UI express package. Run the server and go to the /docs route on your browser. The src/docs folder contains swagger config and all the schema and route specifications.

API Endpoints

List of available endpoints:

Auth routes:

POST /auth/login - login user

User routes:

POST /users - create user
GET /users/:userId - get user by ID
POST /users/:userId - update user by ID
DELETE /users/:userId - delete user by ID

License

MIT

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.