This is an API for a blog app. This API has a general endpoint that shows a list of articles that have been created by different people, and anybody that calls this endpoint, should be able to read a blog created by them or other users.
- Users should have a first name, last name, email, password.
- A user should be able to sign up and sign in into the blog app
- Use JWT as authentication strategy and expire the token after 1 hour
- A blog can be in two states; draft and published
- Logged in and not logged in users should be able to get a list of published blogs created
- Logged in and not logged in users should be able to to get a published blog
- Logged in users should be able to create a blog.
- When a blog is created, it is in draft state
- 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 endpoint should be paginated and filterable by state
- 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.
- Install NodeJS, mongodb
- pull this repo
- update env with example.env
- run
npm run dev
field | data_type | limitations |
---|---|---|
id | string | required |
firstName | string | optional |
lastName | string | optional |
string | required | |
phoneNumber | number | required |
password | string | required |
field | data_type | constraints |
---|---|---|
id | string | required |
title | string | required , unique |
state | string | default: "draft" enum: ['draft', 'published'] |
description | string | required |
author | string | required |
reading_time | string | required |
read_count | number | required |
tags | array | required |
body | atring | required |
user | string | reference : User model |
Visit this site for my Postman documentation of the APIs
PS C:\Users\Amarachi Celine\blogging_API>
$ npm run test
> [email protected] test
> jest --detectOpenHandles.unref()
console.log
Connection to MongoDB is Successful
at NativeConnection.log (src/db/db_connect.js:11:13)
console.log
Connection to MongoDB is Successful
at NativeConnection.log (src/db/db_connect.js:11:13)
POST /api/v1/auth/signup 201 8919.972 ms - 499
POST /api/v1/auth/login 200 260.462 ms - 202
PASS src/tests/auth.test.js (38.617 s)
user signup and login
√ should signup a new user (9469 ms)
√ should signin a user (304 ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 39.855 s
Ran all test suites.
...
- AMARACHI CELINE ARINZE