Routes
Routes to interact with and make changes to the Entries table.
HTTP method | Endpoint | Function |
---|---|---|
GET | /entries | List all entries |
GET | /entries/{entry-id} | View a specific entry |
POST | /entries | Add a new entry |
PUT | /entries/{entry-id} | Update the fields of a specific entry |
DELETE | /entries/{entry-id} | Delete a entry musical |
Sample Requests and Responses
Get, create, update, or delete a entry with its associated HTTP methods.
Sample list all entries request
Here is the request to list all entries in JSON format:
GET http://localhost:8888/entries
Sample Response
[
{
"id": 4,
"creationDate": "2017-04-03T04:00:00.000Z",
"text": "Sed eget turpis a pede tempor malesuada. Vivamus quis mi at leo pulvinar hendrerit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque aliquet lacus vitae pede. Nullam mollis dolor ac nisi. Phasellus sit amet urna. Praesent pellentesque sapien sed lacus. Donec lacinia odio in odio. In sit amet elit. Maecenas gravida interdum urna. Integer pretium, arcu vitae imperdiet facilisis, elit tellus tempor nisi, vel feugiat ante velit sit amet mauris. Vivamus arcu. Integer pharetra magna ac lacus. Aliquam vitae sapien in nibh vehicula auctor. Suspendisse leo mauris, pulvinar sed, tempor et, consequat ac, lacus. Proin velit. Nulla semper lobortis mauris. Duis urna erat, ornare et, imperdiet eu, suscipit sit amet, massa. Nulla nulla nisi, pellentesque at, egestas quis, fringilla eu, diam.",
"upvotes": 1,
"downvotes": 2,
"created_at": "2017-04-28 02:19:46",
"updated_at": "2017-04-28 05:13:31"
},
{
"id": 6,
"creationDate": "Thu Apr 27 2017 22:21:58 GMT-0400 (EDT)",
"text": "Donec dapibus orci sit amet elit. Maecenas rutrum ultrices lectus. Aliquam suscipit, lacus a iaculis adipiscing, eros orci pellentesque nisl, non pharetra dolor urna nec dolor. Integer cursus dolor vel magna. Integer ultrices feugiat sem. Proin nec nibh. Duis eu dui quis nunc sagittis lobortis. Fusce pharetra, enim ut sodales luctus, lectus arcu rhoncus purus, in fringilla augue elit vel lacus. In hac habitasse platea dictumst. Aliquam erat volutpat. Fusce iaculis elit id tellus. Ut accumsan malesuada turpis. Suspendisse potenti. Vestibulum lacus augue, lobortis mattis, laoreet in, varius at, nisi. Nunc gravida. Phasellus faucibus. In hac habitasse platea dictumst. Integer tempor lacus eget lectus. Praesent fringilla augue fringilla dui.",
"upvotes": 1,
"downvotes": -2,
"created_at": "2017-04-28 02:22:04",
"updated_at": "2017-04-28 05:12:59"
}
]
Sample view specific entry request
Here is a sample request to view a specific entry with ID 2:
GET http://localhost:8888/entries/2
Sample Response
{
"id": 2,
"creationDate": "2017-04-29T04:00:00.000Z",
"text": "Donec dapibus orci sit amet elit. Maecenas rutrum ultrices lectus. Aliquam suscipit, lacus a iaculis adipiscing, eros orci pellentesque nisl, non pharetra dolor urna nec dolor. Integer cursus dolor vel magna. Integer ultrices feugiat sem. Proin nec nibh. Duis eu dui quis nunc sagittis lobortis. Fusce pharetra, enim ut sodales luctus, lectus arcu rhoncus purus, in fringilla augue elit vel lacus. In hac habitasse platea dictumst. Aliquam erat volutpat. Fusce iaculis elit id tellus. Ut accumsan malesuada turpis. Suspendisse potenti. Vestibulum lacus augue, lobortis mattis, laoreet in, varius at, nisi. Nunc gravida. Phasellus faucibus. In hac habitasse platea dictumst. Integer tempor lacus eget lectus. Praesent fringilla augue fringilla dui.",
"upvotes": 0,
"downvotes": 0,
"created_at": "2017-04-28 05:13:13",
"updated_at": "2017-04-28 05:13:13"
}
Sample add entry request
Here is a sample add entry request:
POST http://localhost:8888/entries
parameter name: creationDate
value: 2017-04-30T00:00:00.000Z
parameter name: text
value: Last night, I had a dream. I found myself in a desert called cyberland.
parameter name: upvotes
value: 0
parameter name: downvotes
value: 0
The above POST request would create a new entry in the database with the specified parameters.
Parameter Descriptions
- creationDate - the date on which the entry was created
- text - the text of the dream journal entry
- upvotes - the number of upvotes the entry has
- downvotes - the number of downvotes the entry has
Sample Response
{
"entry created": true
"id": 1
}
Sample update entry request
Here is a sample update entry request:
PUT http://localhost:8888/entries/1
parameter name: text
value: Out of the abyss walked a cow. Her name was Elsie.
parameter name: creationDate
value: 2017-04-01T00:00:00.000Z
The above PUT request would update the 'text' and 'creation' fields of the entry with ID 1.
Sample Response
{
"entry updated": true
}
Sample delete entry request
Here is a sample delete entry request:
DELETE http://localhost:8888/entries/1
The above DELETE request would delete the entry with ID 1.
Sample Response
{
"entry deleted": true
}