Giter Club home page Giter Club logo

men-pp-template's Introduction

Open Source Love GitHub

men-pp-template

MongoDB, Express, NodeJS template with Passport authentication.

How to use

  1. Clone repo
  2. npm i
  3. npm i -g pm2
  4. Remeber to change config in ecosystem.config.js.
  5. pm2 start
  6. To view logs: pm2 logs

ecosystem.config.js file

module.exports = {
  apps: [
    {
      name: "men-pp-template",
      script: "./index.js",
      watch: true,
      args: ["--color"],
      instances: 1,
      exec_mode: "cluster",
      env: {
        HTTP_PORT: 8080,
        NODE_ENV: "development",
        MONGO_URI: `mongodb://localhost:27017/sample-db`,
        JWT_SECRET: "supersecret",
        BCRYPT_ROUNDS: 10,
        VERIFY_ALGORITHM: ["HS256"],
        TOKEN_ISSUER: "server",
        JWT_EXPIRES_IN: "1h",
        SIGN_ALGORITHM: "HS256"
      }
    }
  ]
};

How to edit

File Functionality
/controllers/index.js To add API endpoints
/middleware/index.js To add middlewares to the Express app
/models/index.js To add Mongoose schemas and @Hapi/Joi validation schemas
/services/index.js To add functions to the controllers
/keys/index.js To add ENV variables

API endpoints

Method Endpoint Description Examples
GET / Welcome message http:localhost:8080/
GET /usernames Get all usernames (needs authentication) http:localhost:8080//usernames
POST /sign-up Sign up http:localhost:8080//sign-up
Body parameters:
{"username" : "Niweera", "password" : "secret"}
POST /sign-in Sign in http:localhost:8080//sign-in
Body parameters:
{"username" : "Niweera", "password" : "secret"}

Resources:

  1. PM2 Docs
  2. Mongoose Docs
  3. Passport Docs
  4. Joi Docs
  5. jsonwebtoken Docs

PRs are welcome

men-pp-template's People

Contributors

niweera avatar

Watchers

James Cloos 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.