This is a straightforward boilerplate for building REST APIs with ES6 and Express.
- ES6 support via babel
- REST resources as middleware via resource-router-middleware
- CORS support via cors
- Body Parsing via body-parser
Tip: If you are using Mongoose, you can automatically expose your Models as REST resources using restful-mongoose.
# clone it
git clone git@github.com:developit/express-es6-rest-api.git
cd express-es6-rest-api
# Make it your own
rm -rf .git && git init && npm init
# Install dependencies
npm install
# Run it
set PORT=8081 & npm start
# With nodemon:
PORT=8080 nodemon
MIT
Get all players: GET -> http://localhost:8080/api/player
Get root: GET -> http://localhost:8080/api/
Create player: POST -> http://localhost:8080/api/player/create JSON -> { "name": "Amila Nilantha", "birthday": "August 24", "height": "5 8", "weight": "61kg", "description": "All rounder", "battingStyle": "Right handed", "bowlingStyle": "Right arm medium pace", "team": "Grasshoppers", "division": "Divition-3", "season": "Autumn-Winter 2017", "match": "1", "runs": 20, "runsConceded": 8, "oversBowled": 2, "wickets": 1, "catches": 1, "contribution": 12, "outs": 2 }
Get player with name: GET -> http://localhost:8080/api/player/Amila Nilantha
Delete player with name: GET -> http://localhost:8080/api/player/delete/Amila Nilantha