NodeJS sample Rest API
This is very simple RestAPI that you can use as a start point and add your customization
Installation instructions
-
Clone using git
git clone https://github.com/bakrisoft/nodejs_restapi.git -
Open cmd or powersell within project folder to install required modules using npm
npm i --save -
Restore MySQL database file named 'restapi.sql' into your MySQL server and modify the database config in 'shared/db.js' file to match your server
-
Start the api using node command
node server.js
- Get all users
Method: Get
URL: http://localhost:3500/users
-
Get user by id
Method: Get
URL: http://localhost:3500/users/1 -
Create user
Method: Post
URL: http://localhost:3500/users
Body(JSON):
{ "userName": "user1", "userPass": "123", "isActive": 1 } -
Update user
Method: Put
URL: http://localhost:3500/users/1
Body(JSON):
{ "userName": "user1", "userPass": "123", "isActive": 1 } -
Delete user
Method: Delete
URL: http://localhost:3500/users/1
Or simply you can import Postman collection from file 'SampleRestAPI.postman_collection.json'
Waiting for your suggestions