express-booster

    1.1.0 • Public • Published

    A Fast Production Ready Generator tool for structured API node express applications

    Key FeaturesHow To UseCreatorContributeLicense

    https://www.npmjs.com/package/express-booster

    Recordit GIF

    Key Features

    • project structure generation with Services ,Models, Controllers and Routers
    • auto-required Routes using a user specified endpoint and the Route file name

    eg (route : users.js and endpoint: /api this will automount to /api/users)

    • fully implemented Authentication using Passport-jwt
    • suppports mongodb mongoose
    • automatic integration with passport-mongoose
    • helmet package for a more secure express app
    • cors support
    • morgan support for logging
    • nodemon support for Dev

    Table of Contents

    Contents of this documentation.


    Installation

    • npm i express-booster -g

    Setup

    • fillout the Configuration at /src/config/config.js:
    module.exports = {
      db: {
        dbHostName: "localhost",
        dbPort: 27017,
        dbName: "HelloWorld",
      },
      hostname: "localhost",
      port: process.env.PORT || 8081,
      secretKey: "_Fill_ME_",
    };
    ));

    Clone

    • Clone this repo to your local machine using https://github.com/Samielleuch/express-booster.git

    How to use

    • In order to use this CLI package simply:
    $ express-booster

    specify the project name to the CLI tool this will create the folder for your project

    make sure the Folder doesn't already exist

    specify included packages with < space > according to the chosen options this will generate your project

    Files Generation

    • choosing passport-jwt generates /services/passportService.js

    • choosing mongoose generates /models/user.js

    • choosing mongoose and passport-jwt generates :

      • /routers/routes/HelloWorld.js
      • /routers/routes/users.js
      • /controllers/helloWorldController.js
      • /controllers/authController.js

    Route Generation

    • using passport-jwt and mongoose will autogenerate the following routes:

    lets call Main_endpoint the endpoint created when calling the cli app (defaults to /)

    • POST Main_endpoint/users/signin
    • POST Main_endpoint/users/signUp

    these endpoints use the authController and the users route to create jwt authentication login and signup

    sign up example

    POST request to : /users/signup
    {
        "name" : "test" ,
        "phone": 123456789 ,
        "password" : "test" 
      
    }
    response:
    {
        "success": true,
        "status": "Registration Successful!"
    }

    sign in example

    POST request to : /users/signin
    {
        "name" : "test" ,
        "phone": 123456789 ,
        "password" : "test" 
      
    }
    response:
    {
        "success": true,
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjAzOGI3YWM4YTYxZTE4YzVlNDlmM2QiLCJpYXQiOjE1OTQwNjgxMjIsImV4cCI6MTU5NDA3MTcyMn0.Ko2GhbRHpS8Q5i9wBDryYNhYdCbZlir-6iOfRsz1GOE",
        "user": {
            "admin": false,
            "_id": "5f038b7ac8a61e18c5e49f3d",
            "name": "test",
            "phone": 123456789,
            "__v": 0
        }
    }
    • GET Main_endpoint/HelloWorld
    • GET Main_endpoint/HelloWorld/protected

    this endpoint simulates a protected data using jwt tokens you need to specify jwt token in Header to access the protected resource

    access protected data

    GET request to : /HelloWorld/protected
    provide following Header:
    Key Value
    Authorization Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjAzOGI3YWM4YTYxZTE4YzVlNDlmM2QiLCJpYXQiOjE1OTQwNjgxMjIsImV4cCI6MTU5NDA3MTcyMn0.Ko2GhbRHpS8Q5i9wBDryYNhYdCbZlir-6iOfRsz1GOE
    response:
    {
        "msg": "Hello World with jwt :D "
    }

    Contributing

    This is an opensource project every help would be greatly appreciated To get started...

    Step 1

    • Option 1

      • 🍴 Fork this repo!
    • Option 2

      • 👯 Clone this repo to your local machine using https://github.com/Samielleuch/express-booster.git

    Step 2

    • HACK AWAY! 🔨🔨🔨

    Step 3


    Creator



    Sami Elleuch

    - If you want to help, you can contact me at anytime.

    Support

    Give it a try , Every FeedBack is very appreciated

    Reach out to me at one of the following places!


    License

    License

    Install

    npm i express-booster

    DownloadsWeekly Downloads

    3

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    23.1 kB

    Total Files

    18

    Last publish

    Collaborators

    • samielleuch