Giter Club home page Giter Club logo

node-express-boilerplate's Introduction

Node Express Boilerplate

Installation Guide

System Package Dependencies :-

Nodejs: Download version:- >= v10.16.3

Development Setup :-

  1. Clone the repository and install dependencies

    git clone https://github.com/PSPenta/node-express-boilerplate.git
    npm install ( If wants to work with existing version of packages )
    npm run update:packages ( If wants to work with latest version of packages )
  2. To start with database configuration create .env file from referencing the env.example file. For MongoDB install Mongoose package

    npm i -S mongoose mongoose-aggregate-paginate-v2

    For SQL DB install Sequelize package

    npm i -S sequelize sequelize-paginate

    Sequelize supports multiple dialects for RDBMS One of the following command with respect to database:

    npm install --save pg pg-hstore 	# postgres dialect
    npm install --save mysql2 		# mysql dialect
    npm install --save mariadb 		# mariadb dialect
    npm install --save sqlite3 		# sqlite dialect
    npm install --save tedious 		# mssql dialect
  3. After that, if using Sequelize, create database to complete the DB connection.

  4. If you want to use DB migrations, you can use sequelize-cli as a dev dependency

    npm install --save-dev sequelize-cli
  5. Otherwise if you have all the tables already created and you want to import them all at once, you can use sequelize-auto module

    npm install sequelize-auto
    node src/scripts/createModels.js
  6. To run tests

    npm test
  7. Start the application

    npm start
  8. To test code against linting standards

    npm run lint

Local Authentication Service Setup

  1. Add environment variables in .env file referencing from env.example file.
  2. In app.js file require passport.js and the src/services/authServices.js and initialize passport.js.
    const passport = require('passport');
    require('./src/services/authServices');
    passport.initialize();
  3. To create a JWT token use createToken() from authServices.js which takes object and add it in token.
  4. To authenticate any routes use passport.authenticate() as middleware on it.
const passport = require('passport');
router.use('/demo', passport.authenticate('jwt', { session : false }), (req, res) => {});
- Please remove this README.md file when working with live project.

node-express-boilerplate's People

Contributors

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