Skip to content
lrth06 edited this page Oct 2, 2022 · 6 revisions

Authentication

Role based JWT authentication is used. Roles are embedded in the JWT token. The token is sent in the Authorization header.

Role Description
site:admin Can do anything
site:moderator Can moderate content
user:basic Minimal access rights

Client Routes

Method Path Public Description
GET / true Application homepage
GET /auth/login true Login page
GET /auth/register true Register page
GET /rooms false Room directory
GET /rooms/:id false Individual room

API Routes

Method Path Public Description
GET /api/v1 true API homepage
POST /api/v1/auth/login true Login
POST /api/v1/auth/logout false Logout
GET /api/v1/users false Get all users
POST /api/v1/user true Register
GET /api/v1/user/:id false Get user information
PUT /api/v1/user/:id false Update user information
PATCH /api/v1/user/:id false Update user information
DELETE /api/v1/user/:id false Delete user
GET /api/v1/rooms false Get all rooms
POST /api/v1/room false Create room
GET /api/v1/room/:id false Get room information
PUT /api/v1/room/:id false Update room information
PATCH /api/v1/room/:id false Update room information
DELETE /api/v1/room/:id false Delete room
GET /api/v1/random false Get random uuid
POST /api/v1/upload false Upload file(s)
API Route Details

The API uses JSON objects for all requests and responses. The following is a list of all the API routes and their expected JSON objects.

Some routes require authentication or escalated privledges. These routes will return a 401 Unauthorized error if the user is not logged in or does not have the required privledges.


GET /api/v1
API homepage

Example Response:

Thank you for using the go-chat api, please refer to the documentation for more information.
POST /api/v1/auth/login
Login

Example Request:

    {
        "email": "test@test.com",
        "password": "password"
    }

Example Response:

    {
        "msg": "User logged in successfully",
        "token": "eyasdffdsUlkjljhbuioUJH.asjklfhawfeakljhfekajlefheklajh"
    }

Websocket Routes

Clone this wiki locally