Skip to content

mfaishal82/IP-RMT46

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 

Repository files navigation

IP-RMT46

Link web: https://ip-mf-d750f.web.app API server: https://project.mf-cyberse.online/

API DOCS

Rest API Endpoints

List of available endpoints:

GET /pub
GET /pub/:id

POST /register
POST /login

GET /contents
POST /contents
PUT /contents/:id
DELETE /contents/:id

GET /categories
GET /categories/:id
POST /categories
PUT /categories/:id
DELETE /categories/:id

GET /pub

Get public data.

Response (200 - OK)

{
    data: [
        {
            "id": "string",
            "title": "string",
            "translations": [Array]
        },
        ...,
    ],
    "meta": 
        {
        "current_page": "1",
        "last_page": 35,
        "total_items": 697,
        "per_page": 20
        }
}

GET /pub/:id

Get specific public data by Id.

  • Request Params:

    {
        id: integer
    }
    

Response (200-OK)

{
    "id": "integer",
    "title": "string",
    "hadeeth": "text",
    "attribution": "string",
    "grade": "string",
    "explanation": "text",
    "hints": [Array],
    "categories": [Array],
    "translations": [Array]
}

POST /register

Register a new user

  • Request Body

    {
      "username": "string",
      "email": "string",
      "password": "string"
    }
    

    Response (200 - OK)

    {
        "username": "string",
        "email" : "string"
    }
    
    

POST /login

Log in an existing user

  • Request Body

    {
      "email": "string",
      "password": "string"
    }
    

    Response (200 - OK)

    {
      "accessToken": "<access_token>"
    }
    

GET /contents

Get all contents

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Response (200 - OK)

[
  {
    "id": "integer",
    "title": "string",
    "description": "text",
    "UserId": "integer",
    "CategoryId": "integer",
    "createdAt": "date",
    "updatedAt": "date",
    "Category": {
        "id": "integer",
        "name": "String",
        "createdAt": "date",
        "updatedAt": "date"
    }
  }
]

GET /contents/:id

Get content by id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
    "id" : "integer"
}

Response (200 - OK)

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

POST /contents

Create a new content

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Body

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

Response (200 - OK)

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

PUT /contents/:id

Update content by Id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
  "id": "integer"
}

Request Body

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

Response (200 - OK)

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

DELETE /contents/:id

Delete content by Id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
  "id": "integer"
}

Request Body

{
    "title" : "string",
    "description" : "text",
    "CategoryId" : "integer:
}

Response (200 - OK)

{
    message: `Deleted content <content.title>`
}

GET /categories

Get all categories

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Response (200 - OK)

[
  {
    "name": "string"
  },
  ...,
]

GET /categories/:id

Get specific category by Id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
    "id" : "integer"
}

Response (200 - OK)

{
    "name" : "string"
}

POST /categories

Create a new category (only admin)

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Body

{
  "name": "string"
}

Response (200 - OK)

{
  "name": "string"
}

PUT /categories/:id

Update category by Id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
  "id": "integer"
}

Request Body

{
  "name": "string"
}

Response (200 - OK)

{
  "name": "string"
}

DELETE /categories/:id

Delete category by Id

  • headers:
{
  "Authorization": "Bearer <access_token>"
}

Request Params

{
  "id": "integer"
}

Request Body

{
  "name": "string"
}

Response (200 - OK)

{
  "name": "string"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 65.0%
  • JavaScript 32.5%
  • CSS 2.5%