Code Monkey home page Code Monkey logo

node-rem's Introduction

Node REM

NodeJS Rest Express MongoDB (REM) - a production-ready lightweight backend setup.

Build Status Maintainability

๐ŸŒŸ It rains cats and dogs features:

  Typescript      Express 4.15       CORS     Helmet    DotEnv   joi (validation)   forever
  Mongoose 4.9    Passport  JWT      Await
  Tslint          Apidoc    Docker   Husky    Morgan    Travis   Windows (Powershell)
  Tests
            Mocha  Chai     Sinon    istanbul
  MORE:
            HTTPS           HTTP2 (spdy)      Socketio 2.1       Init DB Data
            Slack message   Nodemailer        Mailgun            Email Templates    Forgot Password
            VSCode Debug    Dependabot        Codacy             File upload (multer)
      API
            API response    (data, meta: limit, offset, sort)    Transform res
            apiJson         Pagination query
            Regex query     Whitelist fields in response         Populate deep fields
            mstime          API response time     Stack trace in Response

๐Ÿ“ฆ Installation

Clone this project:

git clone https://github.com/ngduc/node-rem.git your-app
cd your-app
rm -rf .git
yarn
  • Update package.json and .env file with your information.
  • Run yarn dev, it will create a new Mongo DB "node-rem"
  • Verify: use Postman to POST https://localhost:3009/v1/auth/register to create a new user. (set payload to have email, password)

๐Ÿ”ง Commands

Require: MongoDB and NodeJS v8.12.0 +

yarn dev      launch DEV mode
yarn start    launch PROD mode
yarn stop

yarn test     Run tests   (requires MongoDB)

๐Ÿ“– Features

Your simple API Route Handler will have a nice syntax like this: (packed with vitamins cool stuffs)

exports.list = async (req: Request, res: Response, next: NextFunction) => {
  try {
    const data = (await User.list(req)).transform(req); // query & run userSchema.transform() for response
    apiJson({ req, res, data, model: User }); // return standard API Response
  } catch (e) {
    next(e);
  }
};

API Response is similar to JSON API standard:

GET https://localhost:3009/v1/users?fields=id,name&name=*john* (get id & name only in response)
GET https://localhost:3009/v1/users?role=admin&page=1&perPage=20 (query & pagination)
GET https://localhost:3009/v1/users?role=admin&limit=5&offset=0&sort=email:desc,createdAt
{
    "meta": {
        "limit": 5,
        "offset": 0,
        "sort": {
            "email": -1,
            "createdAt": 1
        },
        "totalCount": 4,
        "timer": 3.85,
        "timerAvg": 5.62
    },
    "data": [
        {
            "id": "5bad07cdc099dfbe49ef69d7",
            "name": "John Doe",
            "email": "[email protected]",
            "role": "admin",
            "createdAt": "2018-09-27T16:39:41.498Z"
        },
        // more items...
    ]
}

Example of generated API Docs (using apidoc) - https://node-rem.netlify.com

๐Ÿ“– Documentation

๐Ÿ™Œ Thanks

All contributions are welcome!

danielfsousa/express-rest-es2017-boilerplate

node-rem's People

Contributors

ngduc avatar dependabot-support avatar dependabot-preview[bot] avatar greenkeeper[bot] avatar jipingwang 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.