Public
Documentation Settings

Backend

Introduction

This is our backend service for our inclass project UniFree for CSC59939, instructed by Nikolai Avteniev

Overview

Server Side Database CRUD Microservice

Authentication

Must sign in to get JWT from POST User Sign In API

Error Codes

  • 200 - Success
  • 400 - Validation Error, please check your queries/body
  • 401 - Autentication Error, must sign in before running any APIs
  • 500 - Internal Server Error, please slack the channel for help

GETHealth Check (Live)

http://localhost:8081/healthcheck

Should return service information

  • 200 - Service is live
  • 500 - Service is not live
HEADERS
Content-Type

application/json

Example Request
curl
curl --location 'http://localhost:8081/healthcheck' \
--header 'Content-Type: application/json' \
--data ''
200 OK
Example Response
json
{
  "status": "success",
  "data": {
    "online": true,
    "version": "1.0.2"
  }
}
Server

Cowboy

Connection

keep-alive

X-Powered-By

Express

Access-Control-Allow-Origin

*

Content-Type

application/json; charset=utf-8

Content-Length

61

Etag

W/"3d-ttKRPc49+pnd3jIO9x/G8i+2Hv8"

Vary

Accept-Encoding

Date

Wed, 01 Jan 2020 16:17:00 GMT

Via

1.1 vegur

POSTUser sign in (Live)

http://localhost:8081/api/v1/signin

Should Sign in with corresponded body, when it's signed in successfully. It should output the username and JWT

json
{
    username: required, string,
    password: required, string,
}
  • 200 - Success
  • 400 - Validation Errors
  • 500 - Internal Server Error
HEADERS
Content-Type

application/json

Bodyraw
{
	"username": "songrennew",
	"password": "songrennew"
}
Example Request
curl
curl --location 'http://localhost:8081/api/v1/signin' \
--header 'Content-Type: application/json' \
--data '{
	"username": "jielan2",
	"password": "jielan2"
}'
200 OK
Example Response
json
{
  "status": "success",
  "data": {
    "username": "jielan2",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImppZWxhbjIiLCJpYXQiOjE1NzIxMDA3ODEsImV4cCI6MTU3MjE4NzE4MX0.TkSGQ_7UNJyeh7zcjDqrYF6GhsZ0DzVRp25Olk_q14Y",
    "updatedAt": "2019-10-15T00:43:55.968Z"
  }
}
Server

nginx/1.14.1

Date

Sat, 26 Oct 2019 14:39:41 GMT

Content-Type

application/json; charset=utf-8

Transfer-Encoding

chunked

Connection

keep-alive

X-Powered-By

Express

Access-Control-Allow-Origin

*

Vary

X-HTTP-Method-Override, Accept-Encoding

ETag

W/"100-dWwr/Olo8pwil1D06ScjicV1RSo"

Content-Encoding

gzip

POSTSign Up User Account (Live)

http://localhost:8081/api/v1/signup

Should Sign up with corresponded body

json
{
    email: required, string,
    username: required, string,
    password: required, string,
}
  • 200 - Success
  • 400 - Validation Errors
  • 500 - Internal Server Error
HEADERS
Content-Type

application/json

Bodyraw
{
	"email": "testing00113234@cuny.edu",
	"username": "songren11241",
	"password": "songren11241"
}
Example Request
curl
curl --location 'http://localhost:8081/api/v1/verify' \
--header 'Content-Type: application/json' \
--data-raw '{
	"email": "testing003@citymail.cuny.edu",
	"username": "testing123",
	"password": "songren"
}'
200 OK
Example Response
json
{
  "status": "success",
  "data": {
    "username": "testing123",
    "email": "testing003@citymail.cuny.edu",
    "token": 23567,
    "createdAt": "2019-10-14T22:51:04.001Z"
  }
}
Server

nginx/1.14.1

Date

Mon, 14 Oct 2019 22:51:04 GMT

Content-Type

application/json; charset=utf-8

Transfer-Encoding

chunked

Connection

keep-alive

X-Powered-By

Express

Vary

X-HTTP-Method-Override, Accept-Encoding

ETag

W/"91-VNryrW2Wdm3ZSmZZGMFJckbQKdY"

Content-Encoding

gzip