diff --git a/README.md b/README.md index 1ac8bab..e25e48a 100644 --- a/README.md +++ b/README.md @@ -1 +1,110 @@ -# RESTapi_demo \ No newline at end of file +# Message API using Express js, Mongoose and Heroku + +## Description + +

Wrote up a RESTful API using Node.js, Express js for the main logic and implementation.
+I connected this app to Heroku for cloud deployment and am using mongoose for the database implementation.
+The web app itself can be accessed [here](https://gregs-rest-api-demo.herokuapp.com) and
+you can make curl calls yourself using the URL https://gregs-rest-api-demo.herokuapp.com.

+ +
+ +

For the actual API architeture itself I implemented GET, POST, PUT and DELETE calls.
+The messages themselves consist of and id, a message and a time stamp for when the message was created.
+The id can be used to find a specific message for the GET, PUT and DELETE calls.
+The id is always taken from the request parameter whereas the message is taken from the request body.
+The message Schema is as follows:
+`id: {type:Number, required:true}, +message: {type:String, required:true}, +time: {type:Date, required:true}` +

+ +## Libraries and tools used +- [Express](https://expressjs.com/) +- [Mongodb](https://www.mongodb.com) +- [Mongoose](https://mongoosejs.com/) +- [Morgan](https://github.com/expressjs/morgan), [Helmet](https://github.com/helmetjs/helmet) +- [Mocha](https://mochajs.org/#getting-started), [Chai](http://chaijs.com/api/), [Supertest](https://github.com/visionmedia/supertest) + +## How to + +### Build + +

Clone this repository and install dependencies

+ +`> git clone git@github.com:gjcampbell777/RESTapi_demo.git +> cd express-rest-api + +> npm install` + +### Deploy + +#### Locally + +

Fire up the local server

+ +`node server.js` + +#### Cloud + +

If you have your own HEROKU_API_KEY you can run:

+ +`git push heroku` + +### Access + +#### Locally + +

The web app can now be reached locally at:

+ +`http://localhost:3000/` + +#### Cloud + +

The web app can be accessed through your heroku URL

+ +## REST API Documentation + +### GET + +

To get info on all messages use

+ +`/msg` + +

To get info on one message use

+ +`/msg/:id` + +

The id info is taken from the parameter

+ +### POST + +

To send a message use

+ +`/msg/:id` + +

The id info is taken from the parameter, the message info is taken from the body
+and the timestamp is taken from the API logic

+ +### PUT + +

To update a message use

+ +`/msg/:id` + +

The id info is taken from the parameter and the new message info is taken from the body

+ +### DELETE + +

To delete all messages use

+ +`/msg` + +

To delete one message use

+ +`/msg/:id` + +

The id info is taken from the parameter

+ +## Licence +MIT \ No newline at end of file