Giter Site home page Giter Site logo

cembdc / nodejs-restapi Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 6.0 433 KB

⌛️ Boilerplate for API backends with Node.js and Express.

License: MIT License

JavaScript 99.36% Shell 0.64%
boilerplate nodejs-restapi api-backends nodejs expressjs mongoose mongodb express-boilerplate es6 es2017

nodejs-restapi's Introduction

Nodejs-Restapi-Boilerplate

PRs Welcome Codacy Badge Build Status Coverage Status

A Boilerplate/Starter Project for building RESTful APIs using Node.js, Express, and Mongoose.

Directory structure

Overview

Project src structure directories.

src/
├─ config/
│  ├─ config.js
├─ controller.js
│  ├─ controller.index.js
│  ├─ userController.js
├─ loader/
│  ├─ express.js
│  ├─ mongoose.js
│  ├─ server.js
├─ middlewares/
│  ├─ middlewares.index.js
│  ├─ validator.js
├─ routes/
│  ├─ routes.index.js
│  ├─ routes.js
│  ├─ userRoute.js
├─ utils/
│  ├─ requestUtil.js
│  ├─ utils.index.js
test/
├─ example.test.js
├─ userController.test.js
└─

Features

  • ES9: latest ECMAScript features
  • NoSQL database: MongoDB object data modeling using Mongoose
  • Authentication and authorization: using jsonwebtoken
  • Validation: request data validation using Joi
  • Logging: //TODO: winston
  • Testing: unit and integration tests using Mocha Chai
  • Error handling: centralized error handling mechanism
  • API documentation: //TODO: swagger
  • Dependency management: with Npm
  • Environment variables: using dotenv
  • Security: set security HTTP headers using helmet
  • Santizing: sanitize request data against xss and query injection
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Compression: //TODO: gzip compression with compression
  • CI: continuous integration with Travis CI
  • Docker support
  • Code coverage: using coveralls
  • Code quality: with Codacy
  • Git hooks: with husky
  • Linting: with ESLint and Prettier
  • Editor config: consistent editor configuration using EditorConfig

Getting Started

Installation

Clone the repo:

git clone https://github.com/CemBdc/nodejs-restapi.git
cd nodejs-restapi

Install the dependencies:

npm install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Commands

Running locally:

npm run start

Lint

# lint code with ESLint
npm run lint

Test

# run all tests with Mocha
npm run test

# run test coverage
npm run test:coverage

Contributing

Contributions are more than welcome! Please check out the contributing guide.

Inspirations

License

MIT

nodejs-restapi's People

Contributors

cembdc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.