Giter VIP home page Giter VIP logo

blog-api's Introduction

Blog API Reference

Register user

Register new user

Parameter Type Description
name string Required User name
email string Required User Email
password string Required User password
age string User age
POST /users
  • Response
{
  "code": 201,
  "user": [
    {
      "id": 1,
      "name": "Suhaib",
      "email": "[email protected]",
      "age": 22,
      "createdAt": "2022-06-11T17:43:05.503Z",
      "updatedAt": "2022-06-11T17:43:05.503Z"
    },
    {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
    }
  ]
}

Login User

Login registered user

Parameter Type Description
email string Required User Email
password string Required User password
POST /users/login
  • Response
{
  "code": 200,
  "user": [
    {
      "id": 1,
      "name": "Suhaib",
      "email": "[email protected]",
      "age": 22,
      "createdAt": "2022-06-11T17:43:05.503Z",
      "updatedAt": "2022-06-11T17:43:05.503Z"
    },
    {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
    }
  ]
}

Logout current session

Logout user from the current device

Parameter Type Description
email string Required User Email
password string Required User password
POST /users/logout
!Authenticated!
  • Response
{
  "code": 200,
  "msg": "Logged out"
}

Logout all session

Logout user from all the device

Parameter Type Description
email string Required User Email
password string Required User password
POST /users/logoutAll
!Authenticated!
  • Response
{
  "code": 200,
  "msg": "Logged out from all the device"
}

Get user profile

Get profile of the current user

GET /users/me
!Authenticated!
  • Response
{
  "code": 200,
  "user": {
    "id": 1,
    "name": "Suhaib",
    "email": "[email protected]",
    "age": 22,
    "createdAt": "2022-06-11T17:43:03.023Z",
    "updatedAt": "2022-06-11T17:43:03.023Z"
  }
}

Edit user profile

Edit current user profile

Parameter Type Description
name string User name
password string User password
email string User email
age string User age
PATCH /users/me
!Authenticated!
  • Response
{
  "code": 200,
  "user": {
    "id": 1,
    "name": "Rafi",
    "email": "[email protected]",
    "age": 21,
    "createdAt": "2022-06-11T17:43:03.023Z",
    "updatedAt": "2022-06-11T17:43:03.023Z"
  }
}

Create blog

Create new blog for login user

Parameter Type Description
title string Required Blog title
description string Required Blog description
POST /blogs/create
!Authenticated!
  • Response
{
  "code": 201,
  "blog": {
    "id": 5,
    "ownerId": 3,
    "title": "My first blog",
    "description": "description of my first blog",
    "createdAt": "2022-06-11T17:46:41.866Z",
    "updatedAt": "2022-06-11T17:46:41.866Z"
  }
}

Get blogs

Get most recent blogs (10 by default)

Parameter Type Description
?limit string Limit the number of blogs fetched from database.(10 default)
?skip string Skip the number of blogs fetched from the database.
GET /blogs
  • Request
"localhost/blogs?limit=2&skip=2"
  • Response
{
  "code": 200,
  "blogs": [
    {
      "id": 2,
      "title": "My second blog",
      "description": "description of my second blog",
      "createdAt": "2022-06-11T17:45:23.882Z",
      "updatedAt": "2022-06-11T17:45:23.882Z",
      "ownerId": 4
    },
    {
      "id": 1,
      "title": "My first blog",
      "description": "description of my first blog",
      "createdAt": "2022-06-11T17:45:12.916Z",
      "updatedAt": "2022-06-11T17:45:12.916Z",
      "ownerId": 4
    }
  ]
}

Get blog by id

Get a specific blog by id

GET /blogs/:id
  • Request
"localhost/blogs/2"
  • Response
{
  "code": 200,
  "blog": [
    {
      "id": 2,
      "title": "My second blog",
      "description": "description of my second blog",
      "createdAt": "2022-06-11T17:45:23.882Z",
      "updatedAt": "2022-06-11T17:45:23.882Z",
      "ownerId": 4
    }
  ]
}

Delete blog

Delete a blog by id

DELETE /blogs/:id
!Authenticated!
  • Request
"localhost/blogs/2"
  • Response
{
  "code": 200
}

blog-api's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.