Giter VIP home page Giter VIP logo

elgo's Introduction

Elgo API Documentation

Endpoints :

List of available endpoints:

  • POST /register
  • POST /login
  • GET /categories
  • POST /posts
  • GET /posts
  • GET /posts/:id
  • DELETE /posts/:id

1. GET /register

Description

  • Create a new user data

Request

body

{
  "email": "string (required)",
  "password": "string (required)"
}

Response

200 - Ok

{
  "status": "string",
  "data": {
    "id": "integer",
    "email": "string"
  }
}

400 - Bad Request

{
  "message": ["Email cannot be null", "Password cannot be null"]
}

or

{
  "message": ["Email cannot be empty", "Password cannot be empty"]
}

or

{
  "message": ["Password must be between 5 and 20 characters"]
}

or

{
  "message": ["email must be unique"]
}

2. GET /login

Description

  • Enter into the system

Request

body

{
  "email": "string (required)",
  "password": "string (required)"
}

Response

200 - Ok

{
  "status": "string",
  "access_token": "string",
  "data": {
    "id": "integer",
    "email": "string"
  }
}

401 - Unauthorized

{
  "message": "Invalid email/password"
}

3. GET /categories

Description

  • Get all the categories data

Request

headers

{
  "access_token": "string (required)"
}

Response

200 - Ok

{
  "status": "string",
  "data": [
    {
      "id": "integer",
      "name": "string",
      "createdAt": "date",
      "updatedAt": "date"
    },
    ...,
  ]
}

4. POST /posts

Description

  • Create a new post data

Request

headers

{
  "access_token": "string (required)"
}

body

{
  "title": "string (required)",
  "content": "string (required)",
  "imgUrl": "string",
  "CategoryId": "integer",
  "AuthorId": "integer"
}

Response

201 - Created

{
  "status": "string",
  "data": {
    "id": "integer",
    "title": "string",
    "content": "string",
    "imgUrl": "string",
    "CategoryId": "integer",
    "AuthorId": "integer",
    "updatedAt": "date",
    "createdAt": "date"
  }
}

400 - Bad Request

{
  "message": ["Title cannot be null", "Content cannot be null"]
}

or

{
  "message": ["Title cannot be empty", "Content cannot be empty"]
}

5. GET /posts

Description:

  • Get all posts from database

Request

headers

{
  "access_token": "string (required)"
}

Response

200 - OK

{
  "status": "ok",
  "data": [
    {
      "id": "integer",
      "title": "string",
      "content": "string",
      "imgUrl": "string",
      "CategoryId": "integer",
      "AuthorId": "integer",
      "createdAt": "date",
      "updatedAt": "date"
    },
    ...,
  ]
}

6. GET /posts/:id

Description:

  • Get post by id

Request

headers

{
  "access_token": "string (required)"
}

params

{
  "id": "integer (required)"
}

Response

200 - OK

{
  "status": "string",
  "data": {
    "id": "integer",
    "title": "string",
    "content": "string",
    "imgUrl": "string",
    "CategoryId": "integer",
    "AuthorId": "integer",
    "createdAt": "date",
    "updatedAt": "date"
  }
}

404 - Not Found

{
  "message": "Post not found"
}

7. DELETE /posts/:id

Description:

  • Delete post by id

Request

params

{
  "id": "integer (required)"
}

Response

200 - OK

{
  "message": "<entity name> success to delete"
}

403 - Forbidden

{
  "message": "You are not authorized to access this page"
}

404 - Not Found

{
  "message": "Movie not found"
}

Global Error

Response

401 - Unauthorized

{
  "message": "Invalid token"
}

500 - Internal Server Error

{
  "message": "Internal server error"
}

elgo's People

Contributors

sakirsyarian avatar

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.