Giter VIP home page Giter VIP logo

mini-wp's Introduction

Register User

  • Method: POST

  • URL </register>

  • Data Params
    Required:

    name=[string]
    email=[string]
    password=[string]

  • Success Response:

    • Code: 201
      Content:
          {
              "_id": "5dbf463e66d4901e33fe6b81",
              "email": "[email protected]",
              "password": "$2a$10$8cEP6gHdxjU7aZimMA8xouv3Xq40htC6ikfpUHOdPsPWVg8IFHpzG",
              "name": "foo",
              "createdAt": "2019-11-03T21:27:26.087Z",
              "updatedAt": "2019-11-03T21:27:26.087Z",
              "__v": 0
          }
  • Error Response:

    • Code: 422 Unprocessable Entity
      Content:
      { "message": [ "Email can not be empty" ] }
      { "message": [ "Name can not be empty" ] }
      { "message": [ "Please fill a valid email address" ] }

    • Code: 409 Conflict
      Content:
      { "message": "User already exist." }

    • Code: 500 Internal Server Error
      Content:
      { "message": "Internal Server Error" }

Login User

  • URL </login>

  • Method: POST

  • Data Params
    Required:

    email=[string]
    password=[string]

  • Success Response:

    • Code: 201
      Content:
          {
              "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkYmY0NjNlNjZkNDkwMWUzM2ZlNmI4MSIsImVtYWlsIjoiYXNkYXNkYXNkQGFzZC5jb20iLCJpYXQiOjE1NzI4MTY1Mjl9.QPqj-wyuPI-pErO-PxDuJqe8a7gHysxRgQ8_yufcwH0"
      
          }
  • Error Response:

    • Code: 401 Unauthorized
      Content:
      { "message": "User not found. Please register." }

Get All Articles

  • URL <_/articles>

  • Method: GET

  • Headers
    Authorization=[string]

  • Data Params
    none

  • Success Response:

    • Code: 201
      Content:
          [
              {
                  "_id": "5dc849754a895a81da0b6ae6",
                  "title": "Aricle 1",
                  "content": "<p>This is the content of article 1/p>",
                  "UserId": "5dc848cd3fca71811dfc4087",
                  "createdAt": "2019-11-10T17:31:33.252Z",
                  "updatedAt": "2019-11-10T17:31:33.252Z",
                  "__v": 0
              },
              {
                 "_id": "5dc849754a895a81da0b6ae6",
                  "title": "Aricle 2",
                  "content": "<p>This is the content of article 2/p>",
                  "UserId": "5dc848cd3fca71811dfc4087",
                  "createdAt": "2019-11-10T17:31:33.252Z",
                  "updatedAt": "2019-11-10T17:31:33.252Z",
                  "__v": 0
              }
          ]
  • Error Response:

    • Code: 401 Unauthorized
      Content:
      { "name": "JsonWebTokenError", "message": "jwt must be provided" }
      { "name": "JsonWebTokenError", "message": "invalid token" }

Delete an article

  • URL </api/articles/{id}>

  • Method: DELETE

  • Headers
    Authorization=[string]

  • Data Params
    None

  • Success Response:

    • Code: 201
      Content:
          {  
              "_id": "5dc849754a895a81da0b6ae6",
              "title": "Aricle 1",
              "content": "<p>This is the content of article 1/p>",
              "UserId": "5dc848cd3fca71811dfc4087",
              "createdAt": "2019-11-10T17:31:33.252Z",
              "updatedAt": "2019-11-10T17:31:33.252Z",
              "__v": 0 
          }  
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { "name": "JsonWebTokenError", "message": "invalid token" }

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.