2021-11-25 21:23:42 -05:00
2021-11-22 18:13:52 -05:00
2021-11-25 21:23:31 -05:00

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

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

S
Description
A basic Application that uses a rest api made from scratch to create, read and update messages
Readme MIT
199 KiB
Languages
JavaScript 99.3%
HTML 0.6%
Procfile 0.1%