Install dependencies:
$ npm installStartup the Server:
$ npm startRun Tests:
$ npm run test| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/posts | List all posts |
| GET | /api/v1/posts/:postId | Query one post |
| POST | /api/v1/posts | Create a new post |
| PUT | /api/v1/posts/:postId/publish | Publish a new post |
| PUT | /api/v1/posts/:postId/unpublish | Unpublish a post |
| DELETE | /api/v1/posts/:postId | Delete a post |
Example: https://niveloio.herokuapp.com/api/v1/posts
Response body:
"message": "all posts",
"posts": [
{
"id": 5,
"title": "what is es6?",
"content": "Lorem Ipsum is simply dummy",
"publish": true,
"unpublish": false
},
{
"id": 7,
"title": "what is nodejs?",
"content": "Lorem Ipsum is simply dummy",
"publish": true,
"unpublish": false
},
{
"id": 6,
"title": "what is javascript?",
"content": "Lorem Ipsum is simply dummy",
"publish": true,
"unpublish": false
},
{
"id": 8,
"title": "what is TDD?",
"content": "Lorem Ipsum is simply dummy",
"publish": true,
"unpublish": false
}
]
}
Response body: Example: https://niveloio.herokuapp.com/api/v1/posts/5
{
"post": {
"id": 5,
"title": "what is es6?",
"content": "Lorem Ipsum is simply dummy",
"publish": true,
"unpublish": false
}
}
Remember to add SECRET="YOUR_SECRET_KEY" in your .env file
npm update
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/users | List all users |
| POST | /api/v1/register | Register a new user |
| POST | /api/v1/login | Log in a user |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/protected | Testing protected route |
{
"names": "John Doe",
"username": "johndoe",
"email": "[email protected]",
"password": "secret"
}
{
"email": "[email protected]",
"password": "secret"
}