Skip to content

Linda-Hanson/Blog-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog Api

This is an api for a blog app


Requirements

  1. User should be able to register
  2. User should be able to login with JWT authentication
  3. Implement basic auth
  4. User should be able to get all blog posts
  5. Users should be able to create blog posts
  6. Test application

Setup

  • Install NodeJS, mongodb
  • pull this repo
  • update env with example.env
  • run npm start

Base URL

Models


UserDB

field data_type constraints
id string required
firstname string required
lastname string required
email string required
password string required
created_at date required

blogPost

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

|

APIs


Signup User

  • 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",
    }
}

Login User

  • Route: /login
  • Method: POST
  • Body:
{
  "password": "Password1",
  "email": 'doe@example.com",
}
  • Responses

Success

{
    message: 'Login successful',
    token: 'sjlkafjkldsfjsmfanajdnd'
}

Create post

  • 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 
}

Get postById

  • 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
}

Contributor

  • linda hanson

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors