All Projects → stackinflow → node-rest-api-starter

stackinflow / node-rest-api-starter

Licence: MIT license
This repository is a template to avoid rewriting all the basic authentication code for REST API's built with Express.js, MongoDB.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to node-rest-api-starter

Node Express Mongodb Jwt Rest Api Skeleton
This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API). Demo of frontend in VueJS here: https://github.com/davellanedam/vue-skeleton-mvp
Stars: ✭ 603 (+1910%)
Mutual labels:  mocha, jwt-authentication
TvrboReact
Dream starter project: React, Redux, React Router, Webpack
Stars: ✭ 13 (-56.67%)
Mutual labels:  mocha, jwt-authentication
MyAPI
A template to create awesome APIs easily ⚡️
Stars: ✭ 117 (+290%)
Mutual labels:  jwt-authentication, nodejs-api
Tvrboreact
Dream starter project: React, Redux, React Router, Webpack
Stars: ✭ 13 (-56.67%)
Mutual labels:  mocha, jwt-authentication
Nodebestpractices
✅ The Node.js best practices list (December 2021)
Stars: ✭ 72,734 (+242346.67%)
Mutual labels:  mocha
Testdeck
Object oriented testing
Stars: ✭ 206 (+586.67%)
Mutual labels:  mocha
Yarsk
Don't use this, use Create React App
Stars: ✭ 199 (+563.33%)
Mutual labels:  mocha
Feathers Vue
A boiler plate template using Feathers with Email Verification, Vue 2 with Server Side Rendering, stylus, scss, jade, babel, webpack, ES 6-8, login form, user authorization, and SEO
Stars: ✭ 195 (+550%)
Mutual labels:  mocha
aurelia-dotnet-template
A starting point for new dotnet projects using the aurelia-framework with typescript and webpack.
Stars: ✭ 13 (-56.67%)
Mutual labels:  mocha
laravel-vue-spa-boilerplate
Laravel Vue Spa BoilerPlate
Stars: ✭ 36 (+20%)
Mutual labels:  jwt-authentication
Eslint Plugin Mocha
ESLint rules for mocha
Stars: ✭ 249 (+730%)
Mutual labels:  mocha
Co Mocha
Enable support for generators in Mocha tests
Stars: ✭ 216 (+620%)
Mutual labels:  mocha
Nspec
A battle hardened testing framework for C# that's heavily inspired by Mocha and RSpec.
Stars: ✭ 242 (+706.67%)
Mutual labels:  mocha
Root Cause
🔍 Root Cause is a tool for troubleshooting Puppeteer and Playwright tests. 🔎
Stars: ✭ 205 (+583.33%)
Mutual labels:  mocha
FRDP
Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin ⭐
Stars: ✭ 55 (+83.33%)
Mutual labels:  jwt-authentication
Mocha Parallel Tests
Parallel test runner for mocha tests. Looking for maintainer.
Stars: ✭ 197 (+556.67%)
Mutual labels:  mocha
firebase-functions-typescript-starter
Create & test Firebase Cloud Functions in TypeScript
Stars: ✭ 101 (+236.67%)
Mutual labels:  mocha
Jshistory Cn
🇨🇳 《JavaScript 二十年》中文版
Stars: ✭ 3,686 (+12186.67%)
Mutual labels:  mocha
Babel Plugin Tester
Utilities for testing babel plugins
Stars: ✭ 228 (+660%)
Mutual labels:  mocha
Express Mongoose Es6 Rest Api
💥 A boilerplate application for building RESTful APIs Microservice in Node.js using express and mongoose in ES6 with code coverage and JsonWebToken Authentication
Stars: ✭ 2,811 (+9270%)
Mutual labels:  mocha

Node.js REST API starter

stackinflow Codacy Badge Build Status GitHub issues Twitter URL Gitter GitHub repo size Created Badge Updated Badge

Buy Me A Coffee

This repository is a template to avoid rewriting all the basic authentication code for REST API's built with Express.js, MongoDB.

Table of contents

  1. Why this template
  2. Project architecture and Directories Structure
  3. Tech stack
  4. Install and configure Node.js
  5. MongoDB installation and configuration
  6. Setup and Run the Project
  7. Setup GitHub actions
  8. Authors
  9. Contributing

Why this template

  • This repository includes setup of all basic things required to start a MEAN/MERN stack backend
  • Environments setup
  • Connection to database(MongoDB)
  • Admin routes for handling users
  • Authentication - fully handled
  • Social auth includes Facebook and Google OAuth2 authorization
  • Provides clean structured code
  • Mocha Tests to ensure API is working
  • Email templates for account verification and password reset
  • Token based email verification and OTP based password reset
  • Body field validators

Project architecture and Directories Structure

.
├── api
│   └── v1
│       ├── controllers
│       │   ├── auth.js
│       │   ├── token.js
│       │   └── user.js
│       ├── middlewares
│       │   └── auth.js
│       ├── models
│       │   ├── auth.js
│       │   ├── token.js
│       │   └── user.js
│       ├── routes
│       │   ├── admin
│       │   │   └── auth.js
│       │   ├── auth.js
│       │   └── user.js
│       └── utils
│           ├── constants
│           │   ├── account.js
│           │   ├── collection_names.js
│           │   ├── email_token.js
│           │   ├── error_messages.js
│           │   ├── headers.js
│           │   └── success_messages.js
│           ├── constants.js
│           ├── response.js
│           ├── send_email.js
│           ├── templates
│           │   └── verify_email.pug
│           └── validators.js
├── assets
│   └── banner-node-rest-api.png
├── core
│   ├── config.js
│   ├── db.js
│   ├── helpers.js
│   ├── jwt.js
│   ├── print_env.js
│   └── server.js
├── index.js
├── keys
│   ├── private.pem
│   ├── privater.pem
│   ├── public.pem
│   └── publicr.pem
├── package.json
├── package-lock.json
├── public
│   └── images
├── README.md
├── tests
│   └── v1
│       ├── auth.js
│       └── test.js
└── utils
    ├── ASSET_LICENSES
    ├── bash_scripts
    │   ├── mongodb_setup.sh
    │   ├── node_setup.sh
    │   └── setup_project.sh
    ├── CONTRIBUTING.md
    ├── docs
    │   ├── gh_actions.md
    │   ├── setup_mongo.md
    │   ├── setup_node.md
    │   └── setup_project.md
    ├── node-rest-api-auth.postman_collection.json
    └── swagger
        ├── api
        │   └── v1
        │       ├── auths.yaml
        │       └── paths.yaml
        ├── schemas
        └── swagger.yaml

Tech stack

Node.js, Express.js, MongoDB, JWT, Pug.js, Sendgrid mail

Dependencies

Check package.json file

Tests

Tests are written using Mocha and Chai, here

CI/CD

Runs Tests on pull request is raised

Project setup

Go ahead into the root directory of the repository and follow the below instructions

Note: Setup scripts and docs are written only for Ubuntu based operating system, for other operating systems please refer to respective websites.

For manual setup docs, please refer here,

Installation of Node.js

Execute the below command in terminal

bash utils/bash_scripts/setup_node.sh

MongoDB installation and configuration

Execute the below command in terminal

bash utils/bash_scripts/setup_mongo.sh

Setup and run the project

Execute the below command in terminal

bash utils/bash_scripts/setup_project.sh
  1. Setup environment variables Rename the .env.example as .env and fill up your details there.

SendGrid Create an account at SendGrid SendGrid. Create a new API Key here Verify a sender email and use that email in the .env file, to verify click here

  1. Place your application's Database credentials and config inside the .env.

  2. Install Prettier and ESLint in VS Code

  3. Google and Facebook client details, check out this article for generating client details

  4. Run the project with nodemon (dev server)

npm run dev

or Run as normal project (prod server)

npm start
  1. Run tests
npm test

After running the project, checkout swagger ui at http://localhost:7000/explorer/#/

Setup GitHub actions

Refer this page

Authors

image image
LinkedIn GitHub Twitter Medium LinkedIn GitHub Twitter Medium

Contributing

Check Contributing file

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].