Code Monkey home page Code Monkey logo

express-mysql-boilerplate's Introduction

Express Mysql Boilerplate

A simple boilerplate for building RESTful API with ExpressJS and Mysql

Package

  • ExpressJS
  • Babel
  • Mysql
  • Knex
  • Bookshelf
  • Socket.io

Using API

  • Config your database in knexfile.js
  • Run command
git clone https://github.com/chutiphon-k/express-mysql-boilerplate.git
npm install
npm run build # Migrate and seed database
npm run dev # For run development

RESTful API

HTTP METHOD GET POST PUT PATCH DELETE
/example Get Example Post Example Patch Example Delete Example
/users List users Create new user
/users/:id Get user by id Update user by id Delete user by id

Request & Response Examples

API Resources

GET /users

Example: http://localhost:9090/api/users

Response body:

[
	{
		"id": 1,
		"username": "user1",
		"firstname": "ชุติพนธ์",
		"lastname": "คงสมพรต",
		"nickname": "เจมส์",
		"created_at": "2017-03-11T15:28:58.000Z",
		"updated_at": "2017-03-11T15:28:58.000Z"
	},
	{
		"id": 2,
		"username": "user2",
		"firstname": "สมชาย",
		"lastname": "นะครับ",
		"nickname": "ชาย",
		"created_at": "2017-03-11T15:28:58.000Z",
		"updated_at": "2017-03-11T15:28:58.000Z"
	},
	{
		"id": 3,
		"username": "user3",
		"firstname": "สมหญิง",
		"lastname": "นะค่ะ",
		"nickname": "หญิง",
		"created_at": "2017-03-11T15:28:58.000Z",
		"updated_at": "2017-03-11T15:28:58.000Z"
	}
]

POST /users

Example: Create – POST http://localhost:9090/api/users

Request body:

{
	"username": "user4",
	"firstname": "hello",
	"lastname": "world",
	"nickname": "haha",
}

GET /users/:id

Example: http://localhost:9090/api/users/1

Response body:

{
	"id": 1,
	"username": "user1",
	"firstname": "ชุติพนธ์",
	"lastname": "คงสมพรต",
	"nickname": "เจมส์",
	"created_at": "2017-03-11T15:28:58.000Z",
	"updated_at": "2017-03-11T15:28:58.000Z"
}

express-mysql-boilerplate's People

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.