Skip to content

REST API starter using Node.js and Express.js with a simple front-end.

License

Notifications You must be signed in to change notification settings

CameronGuthrie/rest-api-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API starter

Installation

To initialise the project you will need to install several dependencies, open up a git bash terminal from the repo directory and run the command:

$ npm install

Running the application

In order to run the application, from your git bash terminal run:

$ npm start
API Listening on http://localhost:8080

Stopping the application

In order to stop the application from the git bash terminal that is running the server press CTRL + C

Running on a different port

To start the application on an alternative port to the default (8080) from your git bash terminal run:

$ PORT=9090 npm start
API Listening on http://localhost:9090

Functionality

Through the browser

In order to interact with this application through a browser navigate to http://localhost:8080/ or change the port number to the alternative that you have used.

CREATE

To create the example product run the command:

$ curl -s -X POST http://localhost:8080/product/create -H 'Content-type:application/json' -d '{"name":"example product", "description":"this is an example", "price":9.99}'

READ (all)

To read all of the products run the command:

$ curl -s -X GET http://localhost:8080/product/read

READ (one)

To read one of the products run the command:

$ curl -s -X GET http://localhost:8080/product/read/<id>

n.b: For these commands anything surrounded by angled braces <> needs to be replaced by you

UPDATE

To update one of the products run the command:

$ curl -s -X PUT http://localhost:8080/product/update/<id> -H 'Content-type:application/json'  -d '{"name":"updated product", "description":"its brand new", "price":99.99}'

n.b: For these commands anything surrounded by angled braces <> needs to be replaced by you

DELETE

To delete one of the products run the command:

$ curl -s -X DELETE http://localhost:8080/product/delete/<id>

n.b: For these commands anything surrounded by angled braces <> needs to be replaced by you

Testing

To run tests on this project, use the command.

npm test

About

REST API starter using Node.js and Express.js with a simple front-end.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published