Public
Documentation Settings

worksquare_blog

This API documentation is for a blog mangement system. User can create account and manage blogs

Auth

This folder contains all the API that allows user to register and login their account abd generate access token in the process

POSTCreate A User

http://localhost:3090/v1/auth/register
Bodyraw (json)
json
{
    "firstName" : "worksquare",
    "lastName" : "worksquare",
    "email" : "adminworksquaregmail.com",
    "password" : "password1"
}
Example Request
curl
curl --location 'http://localhost:3090/v1/auth/register' \
--data-raw '{
    "firstName" : "worksquare",
    "lastName" : "worksquare",
    "email" : "adminworksquare@gmail.com",
    "password" : "password1"
}'
201 Created
Example Response
json
{
  "user": {
    "id": 5,
    "firstName": "worksquare",
    "lastName": "worksquare",
    "middleName": null,
    "email": "adminworksquare@gmail.com",
    "gender": null,
    "profileImage": null,
    "phoneNumber": null,
    "lastLogin": null,
    "isVerified": false,
    "createdAt": "2023-05-22T20:37:19.000Z",
    "updatedAt": "2023-05-22T20:37:19.000Z",
    "roles": [
      {
        "name": "user"
      }
    ]
  },
  "tokens": {
    "access": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTY4NDc4Nzg0MiwiZXhwIjoxNjg0Nzg5NjQyLCJ0eXBlIjoiYWNjZXNzIn0.n3VfwyUOpzFXTfs-EwuWMMEgt2R5cR-i1t-cLqT62d4",
      "expires": "2023-05-22T21:07:22.940Z"
    },
    "refresh": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTY4NDc4Nzg0MiwiZXhwIjoxNjg3Mzc5ODQyLCJ0eXBlIjoicmVmcmVzaCJ9.fy9yHV2j1u7RKVZBUa8PykPlfuXLt55Z4FDbw0mfTJg",
      "expires": "2023-06-21T20:37:22.980Z"
    }
  }
}
Content-Security-Policy

default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests

X-DNS-Prefetch-Control

off

Expect-CT

max-age=0

X-Frame-Options

SAMEORIGIN

Strict-Transport-Security

max-age=15552000; includeSubDomains

X-Download-Options

noopen

X-Content-Type-Options

nosniff

X-Permitted-Cross-Domain-Policies

none

Referrer-Policy

no-referrer

X-XSS-Protection

0

Access-Control-Allow-Origin

*

Content-Type

application/json; charset=utf-8

Content-Length

764

ETag

W/"2fc-54kLqKkGPMkdHHhkgiliuFHBul0"

Vary

Accept-Encoding

Date

Mon, 22 May 2023 20:37:23 GMT

Connection

keep-alive

Keep-Alive

timeout=5

POSTlogin

http://localhost:3090/v1/auth/login

This API request enable a user to log in to the platform after successful resgistration

Bodyraw (json)
json
{
     "email" : "adminworksquare@gmail.com",
    "password" : "password1"
}
Example Request
curl
curl --location 'http://localhost:3090/v1/auth/login' \
--data-raw '{
     "email" : "adminworksquare@gmail.com",
    "password" : "password1"
}'
200 OK
Example Response
json
{
  "user": {
    "id": 5,
    "firstName": "worksquare",
    "lastName": "worksquare",
    "middleName": null,
    "email": "adminworksquare@gmail.com",
    "gender": null,
    "profileImage": null,
    "phoneNumber": null,
    "lastLogin": null,
    "isVerified": false,
    "createdAt": "2023-05-22T20:37:19.000Z",
    "updatedAt": "2023-05-22T20:37:23.000Z",
    "roles": [
      {
        "name": "user"
      }
    ]
  },
  "tokens": {
    "access": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTY4NDc4ODQxMiwiZXhwIjoxNjg0NzkwMjEyLCJ0eXBlIjoiYWNjZXNzIn0.Nfyt-qVWhpD46GmFtuh46MbvOFZmm2xdoC0zTFaTk40",
      "expires": "2023-05-22T21:16:52.387Z"
    },
    "refresh": {
      "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlhdCI6MTY4NDc4ODQxMiwiZXhwIjoxNjg3MzgwNDEyLCJ0eXBlIjoicmVmcmVzaCJ9.wLXq_I74Vn9M9SmFafHhdq2QRUimDQ3TDr_3V1wvofE",
      "expires": "2023-06-21T20:46:52.388Z"
    }
  }
}
Content-Security-Policy

default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests

X-DNS-Prefetch-Control

off

Expect-CT

max-age=0

X-Frame-Options

SAMEORIGIN

Strict-Transport-Security

max-age=15552000; includeSubDomains

X-Download-Options

noopen

X-Content-Type-Options

nosniff

X-Permitted-Cross-Domain-Policies

none

Referrer-Policy

no-referrer

X-XSS-Protection

0

Access-Control-Allow-Origin

*

Content-Type

application/json; charset=utf-8

Content-Length

764

ETag

W/"2fc-gIr6qveOXberp4ZytBY+MRgu09E"

Vary

Accept-Encoding

Date

Mon, 22 May 2023 20:46:52 GMT

Connection

keep-alive

Keep-Alive

timeout=5

Blog

This folder contains all the Api which allows a user to manage blog.

A user can create, get, update and delete blog.

Unauthorized means the user is not having the access token hence the user must login and generate access token, if the user is new, then the user will create account and log in with his or her email and password.

Invalid id means the user is trying to access what is not in the database e.g id 33 is not in the database so accessing it will be bring out blog not found for route that requires id

POSTcreate blog

http://localhost:3090/v1/blogs
AUTHORIZATIONBearer Token
Token

<token>

Bodyraw (json)
json
{
    "title" : "how to be a good woman in bed",
    "content" : "hhhhhhhgggggggejkWHc.kWEJ.wrCAK"
}
Example Request
curl
curl --location --request POST 'http://localhost:3090/v1/blogs'
401 Unauthorized
Example Response
json
{
  "code": 401,
  "message": "Please authenticate",
  "stack": "Error: Please authenticate\n    at C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\src\\middlewares\\auth.js:24:19\n    at allFailed (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport\\lib\\middleware\\authenticate.js:107:18)\n    at attempt (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport\\lib\\middleware\\authenticate.js:180:28)\n    at strategy.fail (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport\\lib\\middleware\\authenticate.js:302:9)\n    at JwtStrategy.authenticate (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport-jwt\\lib\\strategy.js:96:21)\n    at attempt (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport\\lib\\middleware\\authenticate.js:366:16)\n    at authenticate (C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\node_modules\\passport\\lib\\middleware\\authenticate.js:367:7)\n    at C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\src\\middlewares\\auth.js:50:109\n    at new Promise (<anonymous>)\n    at C:\\Users\\EAGLES WHITELION\\Desktop\\external\\blog\\blog\\src\\middlewares\\auth.js:49:12"
}
Content-Security-Policy

default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests

X-DNS-Prefetch-Control

off

Expect-CT

max-age=0

X-Frame-Options

SAMEORIGIN

Strict-Transport-Security

max-age=15552000; includeSubDomains

X-Download-Options

noopen

X-Content-Type-Options

nosniff

X-Permitted-Cross-Domain-Policies

none

Referrer-Policy

no-referrer

X-XSS-Protection

0

Access-Control-Allow-Origin

*

Content-Type

application/json; charset=utf-8

ETag

W/"503-BvFPpkgOJIVUW+zBurC3F4Ywtyg"

Vary

Accept-Encoding

Content-Encoding

gzip

Date

Mon, 22 May 2023 20:54:00 GMT

Connection

keep-alive

Keep-Alive

timeout=5

Transfer-Encoding

chunked