API Documentation: https://documenter.getpostman.com/view/19301718/2s8YRcPwtt
- User should be able to sign up and sign in
- Use JWT as authentication strategy and expire the token after 1 hour
- Logged in users should be able to create a blog.
- Logged in and not logged in users should be able to get a list of published blogs created
- When a blog is created, it is in draft state
- Blogs created should have title, description, tags, author, timestamp, state, read_count, reading_time and body.
- A blog can be in two states; draft and published
- Logged in and not logged in users should be able to to get a published blog
- The owner of the blog should be able to update the state of the blog to published
- The owner of a blog should be able to edit the blog in draft or published state
- The owner of the blog should be able to delete the blog in draft or published state
- The owner of the blog should be able to get a list of their blogs.
- The list of blogs endpoint that can be accessed by both logged in and not logged in users.
- When a single blog is requested, the api should return the user information(the author) with the blog. The read_count of the blog too should be updated by 1
- Test Application
- Install NodeJs, mongodb
- pull this repo
- create
.env
file- specify a PORT number:
PORT=3333
- connect mongodb:
MONGODB_CONNECTION_URL=mongodb://localhost/
- specify a JWT_SECRET:
JWT_SECRET=something-secret
- specify a PORT number:
- run
npm run start
field | data_type | constraints |
---|---|---|
id | string | required |
string | required, unique | |
first_name | string | required |
last_name | string | required |
password | string |
field | data_type | constraints |
---|---|---|
id | string | required |
title | string | required, unique |
description | string | |
author | string | required |
state | number | default: 0 |
read_count | number | default: 0 |
reading_time | string | |
tags | [string] | |
body | string | required |
author_id | string | required |
timestamp | timestamp |
- Route:
/api
- Method: GET
- Route:
/api/signup
- Method: POST
- Route:
/api/login
- Method: POST
- Route:
/api/my-blogs
- Method: POST
- Header
- Authorization: Bearer {token}
- Route:
/api/my-blogs
- Method: GET
- Header
- Authorization: Bearer {token}
- Route:
/api/my-blogs/:id
- Method: PATCH
- Header
- Authorization: Bearer {token}
- Route:
/api/my-blogs/:id
- Method: DELETE
- Header
- Authorization: Bearer {token}
- Faleke Peace