Giter VIP home page Giter VIP logo

mn-express-rest-starter's Introduction

Express Rest API Starter

  • Simple project starter point for Rest API using Nodejs & Expressjs.
  • Starter point for learning and practice Nodejs & Expressjs.
  • Inspired by express-mongoose-es6-rest-api.

Get started

Commands

  • Node version >= v6.9.
  • Install packages by yarn or npm.
$ yarn install 
  • Run server (default port: 5000)
$ yarn start 
  • Run for dev with nodemon and eslint
$ yarn dev 

Example some API

  • Swagger API: http://localhost:5000/api/v1/api-docs/
  • Check API is working http://localhost:5000/api/v1/health-check it should response OK.
  • Check API login:
    • POST: http://localhost:5000/api/v1/auth/login
      • Request Body:
      {"username": "react", "password": "express"}
    • Response Payload:
      {
        "data": {
          "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InJlYWN0IiwiaWF0IjoxNTI0NDc4MzcwLCJleHAiOjE1MjQ0ODU1NzB9.Me7AuPzf7NDzmtw9aCdfW8VBpbgiddBYlXFGYMIlvQw",
          "username": "react"
        },
        "success": 1
      }
  • Get random number API:
    • GET: http://localhost:5000/api/v1/auth/randomNumber
      • Request Header:
      Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InJlYWN0IiwiaWF0IjoxNTE4MjU3OTMwfQ.8FfXLMr-j3Is8SVBAs9Xt1SN5-8J110fI0zZ8pG7sXs
    • Response Payload:
      {
        "data": {
          "user": {
            "username": "react",
            "iat": 1524478370,
            "exp": 1524485570
          },
          "num": 26.62498848615844
        },
        "success": 1
      }

TODO

  • Unit Test: mocha, chai.
  • Build Tools, ES7.

License

MIT

mn-express-rest-starter's People

Contributors

ngmikeng avatar

Stargazers

 avatar

Watchers

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