A simple dynamic route,scalable api using node graphql mysql and knex tutorial
- Clone this to a local folder
- Run
npm install
in the local folder
- Update database configuration on
config.js
. Set user,pass,db. - Log into the MySQL terminal, and ceate the database: CREATE DATABASE Bookstore;
- knex migrate:latest
npm start || nodemon start
- All: http://localhost:3000/api/v1/module/books (browser)
- Get: http://localhost:3000/api/v1/module/book/2 (browser)
- Create: curl -X POST -H "Content-Type: application/json" -d '{"name":"Lord of the Fries","isbn":"som3isbnvalu3"}' http://localhost:3000/api/v1/module/books (console)
- Update: curl -X PUT -H "Content-Type: application/json" -d '{"name":"Lord of the Flies","isbn":"978-0-39-950148-7"}' http://localhost:3000/api/v1/module/book/4 (console)
- Delete: curl -X DELETE -H "Content-Type: application/json" http://localhost:3000/api/v1/module/book/2 (console)
Inspired by https://medium.com/@alexanderleon/creating-a-scalable-api-using-node-graphql-mysql-and-knex-710a1a475ff4