Skip to content

TheCyberwrightProject/cyberwright-backend

Repository files navigation

Cyberwright Backend/API Documentation

NestJS TypeScript MongoDB

This API is built with the NestJS framework and utilized MongoDB as a database.

Getting Started

  1. Modify .env.example to .env and alter the contents with the relevant data.
  2. Run npm install to install relevant node modules
  3. Run npm start to start the API

Documentation

You will find documentation about the API's endpoints and their supported methods, required data for requests, and format of responses.

Authentication Endpoint: /auth

1. /auth/signup

  • Description: Allows a user to sign up and create a new account.
  • Method: POST
  • Request Body:
    {
        "name": "user",
        "password": "epicpassword",
        "email": "admin@cyberwright.org"
    }
  • Response:
    {
        "access_token": "JWT_TOKEN"
    }

2. /auth/login

  • Description: Allows a user to log in to an existing account.
  • Method: POST
  • Request Body:
    {
        "password": "epicpassword",
        "email": "admin@cyberwright.org"
    }
  • Response:
    {
        "access_token": "JWT_TOKEN"
    }

3. /auth/validateToken

  • Description: Endpoint to check if a JWT token is valid or not
  • Method: GET
  • Response:
    {
        "valid": true
    }

4. /auth/googleCallback

  • Description: Endpoint to recieve Google callback code and exchange for an access token
  • Method: POST
  • Request Body:
    {
        "code": "[google code]",
        "redirect_uri": "http://localhost:12345/"
    }
  • Response:
    {
        "access_token": "JWT_TOKEN"
    }

User Endpoint: /user

All requests to this endpoint require an access token attached as a Bearer token in the Authorization header.

1. /user/accountInfo

  • Description: Returns an authorized user's account information (name, email, profile picture, etc.).
  • Method: GET
  • Response:
    {
        "name": "user",
        "email": "admin@cyberwright.org",
        "pfp": "https://pfp"
    }

2. /user/changePassword

  • Description: Allows a user to change their password.
  • Method: POST
  • Request Body:
    {
        "new_password": "epicpassword"
    }
  • Response:
    {
        "changed": true
    }

3. /user/disabled

  • Description: Allows a user to check if their account is disabled.
  • Method: GET
  • Response:
    {
        "disabled": true
    }

AI Endpoint: /ai

All requests to this endpoint require an access token attached as a Bearer token in the Authorization header.

1. /ai/initUploadSession

  • Description: Allows a user to initiate an upload session and obtain an upload id.
  • Method: POST
  • Request Body:
    {
        "dir_name": "test",
        "num_files": 3
    }
  • Response:
    {
        "uid": "UUID"
    }

2. /ai/uploadFile

  • Description: Allows a user to upload files to the associated upload ID.
  • Method: POST
  • Request Body:
    uid=Upload ID
    file=@test.txt
    
    (Form data)
  • Response:
    {
        "uploaded": true
    }

3. /ai/scanUpload

  • Description: Allows a user to scan the uploaded files.
  • Method: POST
  • Request Body:
    {
        "uid": "Upload ID",
    }
  • Response:
    {
        "diagnostics": []
    }
    
    
    

4. /ai/getDiagnostics

  • Description: Allows a user to check and obtain their upload's diagnostics
  • Method: POST
  • Request Body:
    {
        "uid": "Upload ID",
    }
  • Response:
    {
        "status": "Some status message",
        "diagnostics": [] || null
    }

About

Backend API source code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published