Skip to content

justinkames/express-es6-rest-api

Repository files navigation

Introduction

POC showcasing CRUD operations with Express JS (ES6) and MySQL. Real time database push notifications with socket.io.

Requirements

  • Node JS ( 6.8.1 )
  • MySQL DB ( execute script @ .bin/create-script.sql ).

Technologies

  • Express 4
  • Angular
  • Gulp JS
  • MySQL
  • ESlint

Features

  • Server reload on file change with nodemon.
  • Unit testing with mocha, sinon and chai (es6).
  • Injectable properties with NPM config module.
  • Rest API example with isolated controller functions for unit testing.
  • MySQL connection and MySQL CRUD examples.
  • Real time communicatoin with socket.io.

Installation development

  • $ npm i or $ yarn

  • $ npm run-script startdev

  • set db credentials in config/dev.json.

  • browse api @ http://localhost:3000/api

  • browse index @ http://localhost:3000

Scripts

  • " $ npm start": "NODE_CONFIG_DIR=lib/config NODE_ENV=prod node .bin",
  • " $ npm run startdev": "NODE_CONFIG_DIR=lib/config NODE_ENV=dev DEBUG=express:router,application nodemon .bin",
  • " $ npm test": "NODE_CONFIG_DIR=lib/config NODE_ENV=dev gulp watch-mocha",

CURL examples

  • curl -X GET localhost:3000/api/todos
  • curl -H "Content-Type: application/json" -X POST -d '{"title":"clean", "description":"clean the house"}' localhost:3000/api/todos
  • curl -H "Content-Type: application/json" -X PUT -d '{"title":"clean", "description":"clean all the houses"}' localhost:3000/api/todos/1

Best Practices

Research & Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published