This is an api for a blog app
- User should be able to register
- User should be able to login with JWT authentication
- Implement basic auth
- User should be able to get all blog posts
- Users should be able to create blog posts
- Test application
- Install NodeJS, mongodb
- pull this repo
- update env with example.env
- run
npm start
| field | data_type | constraints |
|---|---|---|
| id | string | required |
| firstname | string | required |
| lastname | string | required |
| string | required | |
| password | string | required |
| created_at | date | required |
| field | data_type | constraints |
|---|---|---|
| id | string | required |
| title | string | required |
| author | string | required |
| description | string | required |
| body | string | required |
| created_at | date | required |
| updated_at | date | required |
|
- Route: /signup
- Method: POST
- Body:
{
"firstname": "jon",
"lastname": "doe",
"email": "doe@example.com",
"password": "Password1"
}
- Responses
Success
{
message: 'Signup successful',
user: {
"email": "doe@example.com",
"password": "Password1",
"firstname": "jon",
"lastname": "doe",
"username": 'jon_doe",
}
}
- Route: /login
- Method: POST
- Body:
{
"password": "Password1",
"email": 'doe@example.com",
}
- Responses
Success
{
message: 'Login successful',
token: 'sjlkafjkldsfjsmfanajdnd'
}
- Route: /posts/store
- Method: POST
- Header
- Authorization: Bearer {token}
- Body:
{
title : i love javascript
| author : linda hanson
| description : javascript is a programming language
| body: javascript is a webdevelopment scripting language
| created_at : data
| updated_at : date
}
- Responses
Success
{
title : i love javascript
| author : linda hanson
| description : javascript is a programming language
| body: javascript is a webdevelopment scripting language
| created_at : data
| updated_at : date
}
- Route: /post/:id
- Method: GET
- Header
- Authorization: Bearer {token}
- Responses
Success
{
title : i love javascript
| author : linda hanson
| description : javascript is a programming language
| body: javascript is a webdevelopment scripting language
| created_at : data
| updated_at : date
}
- linda hanson