This is an api for a blogging app
https://altschoolafrica.com/schools/engineering
- User should be able to signup
- User should be able to login with Passport using JWT
- Implement basic auth
- All users should be able to get blogs that have been published
- Logged users should be able to create blogs
- Owners should be able to update and delete blogs both published and drafts
- Test application
- Install NodeJS, mongodb
- pull this repo
- update env with example.env
- run
npm start
-https://github.com/olanrewaju443/my-blogger -https://myblog.cyclic.app/
field | data_type | constraints |
---|---|---|
id | string | required |
string | required | |
firstname | string | required |
lastname | string | required |
string | required | |
password | string | required |
field | data_type | constraints |
---|---|---|
id | string | required |
created_at | date | default: date.now |
state | string | required, { published or draft }, default:draft |
title | string | required, unique |
description | string | required |
read_count | number | default: 0 |
reading_time | string | |
tags | array | [] |
body | string | required |
timestamp | date | default: date.now |
author | object | required |
- Route: /signup
- Method: POST
- Body:
{
"email": "[email protected]",
"password": "Password1",
"firstname": "jon",
"lastname": "doe",
}
- Responses
Success
{
status: 'true',
user: {
"email": "[email protected]",
"password": "Password1",
"firstname": "jon",
"lastname": "doe",
}
}
- Route: /login
- Method: POST
- Body:
{
"email": "[email protected]",
"password": "Password1",
}
- Responses
Success
{
token: 'sjlkafjkldsfjsd'
}
- Route: /posts
- Method: POST
- Header
- Authorization: Bearer {token}
- Body:
{
"title": "dan d humorous",
"description": "Daniel is here",
"state": "published",
"tags": "hassle",
"body": "leave this empty"
}
- Responses
Success
{
"status": true,
"blog": {
"title": "dan d humorous",
"description": "Daniel is here",
"state": "draft",
"read_count": 0,
"reading_time": "0 minute(s)",
"tags": [
"hassle"
],
"body": "leave this empty",
"timestamp": {
"created_at": "2022-11-05T19:34:52.413Z",
"updated_at": "2022-11-05T19:34:52.414Z"
},
"author": "6364bf34646ec543a1c387e7",
"_id": "6366badcb445977a3226aa3a",
"__v": 0
}
}
- Route: /posts/:id
- Method: GET
- Header
- Responses
Success
{
"status": true,
"blog": {
"timestamp": {
"created_at": "2022-11-04T07:31:48.673Z",
"updated_at": "2022-11-05T04:13:10.360Z"
},
"_id": "6364bfe4772f08c9c4c07451",
"title": "danny",
"description": "Daniel is here",
"read_count": 3,
"reading_time": "0 minute(s)",
"tags": [
"hassle"
],
"body": "leave this empty",
"author": {
"_id": "6364bf34646ec543a1c387e7",
"firstname": "Daniel",
"lastname": "King",
"email": "[email protected]"
},
"__v": 0,
"state": "published"
}
}
- Route: /blogs
- Method: GET
- Header:
- Query params:
- page (default: 1)
- per_page (default: 20)
- blog_by (default: created_at)
- blog (options: asc | desc, default: desc)
- state
- timestamp
- Responses
Success
{
"status": true,
"blog": {
"timestamp": {
"created_at": "2022-11-04T07:31:48.673Z",
"updated_at": "2022-11-05T04:13:10.360Z"
},
"_id": "6364bfe4772f08c9c4c07451",
"title": "danny",
"description": "Daniel is here",
"read_count": 3,
"reading_time": "0 minute(s)",
"tags": [
"hassle"
],
"body": "leave this empty",
"author": {
"_id": "6364bf34646ec543a1c387e7",
"firstname": "Daniel",
"lastname": "King",
"email": "[email protected]"
},
"__v": 0,
"state": "published"
}
}
...
- Adegboye Michael