This is a node RESTful API that uses Express engine and Mongo DB for CRUD operations. You can add, update, retrieve or delete a book record from the books database. The API routes are protected and access authenticated using Json Web Token (jwt)
-
Clone the repo
Run git clone "https://github.com/danmbeyah/Node-REST-API.git" .
-
Update/Install node modules
Run npm update
-
Install dependencies
Run npm install -save express mongodb body-parser jsonwebtoken
-
Install nodemon, a dev dependency to automatically restart server after file changes
npm install --save-dev nodemon
-
Create an account on mLab where your Mongo DB will be hosted (https://mlab.com) For this repo, db is books and collection is books. Change user and password to reflect your settings in config.
npm run dev
Use Postman to run/access the APIs Login using http://localhost:8000/login to get access token. Set token in header for subsequent API calls below. Header {Authorization: Bearer }
POST http://localhost:8000/books Params(title,author,summary)
GET http://localhost:8000/books/:id Params (id is record ID from mLab)
DELETE http://localhost:8000/books/:id Params (id is record ID from mLab)
UPDATE. http://localhost:8000/books/:id Params(title,author,summary)
- Develop React Native app to consume API