Skip to content

Users

User Service File Structure

  • DirectorySNAPCASTER-BACKEND
    • Directoryservices
      • Directoryuser
        • Directorypostgres-init
          • various_tables_init.sql
        • Directorysrc
          • Directoryconfig
            • database.ts
            • discord.ts
            • sesClient.ts
          • Directorycontrollers
            • userController.ts
          • Directorymiddleware
            • authMiddleware.ts
          • Directoryroutes
            • userRoutes.ts
          • Directoryservices
            • sendEmailServices.ts
          • Directorytemplates
            • passwordResetEmail.html
            • passwordResetEmail.txt
            • veritficationEmail.html
            • veritficationEmail.txt
          • Directorytypes
            • types.d.ts
            • types.ts
          • server.ts
        • .dockerignore
        • .gitignore
        • docker-entrypoint.sh
        • Dockerfile
        • nodemon.json
        • package.json
        • pnpm-lock.yaml
        • tsconfig.json

GET /health

The /health endpoint verifies that a connection to the Postgres database can be established.

  1. HTTP 200 OK
  2. HTTP 500 Internal Server Error | Health check failed: Unable to connect to Postgres

POST /register

The /register endpoint creates a user account and stores it into the Postgres database.

  1. HTTP 200 OK | [register object]
  2. HTTP 400 Bad Request | User already exists
  3. HTTP 500 Internal Server Error | Error registering user

Register Object

PropertyTypeDetails
emailStringThe users email
fullNameStringThe users first name and last name
idIntegerThe users ID

Register Parameters

ParameterTypeMandatoryDetails
emailStringMandatoryThe users email
fullNameStringMandatoryThe users first and last name
passwordStringMandatoryThe users password

POST /login

The /login endpoint logs the user in and creates a user session.

  1. HTTP 200 OK
  2. HTTP 401 Unauthorized | Error logging in: [error]
  3. HTTP 500 Internal Server Error | Error logging in

POST /forgot-password

The /forgot-password endpoint connects to Snapcasters AWS SNS and sends a password reset email to the users email address.

  1. HTTP 200 OK | Password reset email sent

Forgot Password Parameters

ParameterTypeMandatoryDetails
emailStringMandatoryThe users email

PUT /update-user (Depreciated)

The /update-user endpoint handles when the user toggles the beta features on and off under their account settings.

  1. HTTP 200 OK | [Update User object]
  2. HTTP 401 Unauthorized | Unauthorized: User not identified
  3. HTTP 404 Not Found | User not found
  4. HTTP 500 Internal Server Errpr | Error updating user

Update User Object

PropertyTypeDetails
beta_features_enabledBooleanThe toggle to enable beta features on an account
emailStringThe users email
full_nameStringThe users full name
idIntegerThe users ID

Update User Parameters

ParameterTypeMandatoryDetails
betaFeaturesEnabledBooleanMandatoryThe toggle to enable beta features on an account

GET /profile

The /profile is used to retrieve the users most basic information such as their subscription status.

  1. HTTP 200 OK | [Profile Object]
  2. HTTP 401 Unauthorized | Unauthorized: User not identified
  3. HTTP 404 Not Found | User not found
  4. HTTP 500 Internal Server Errpr | Error updating user

Profile Object

PropertyTypeDetails
idIntegerThe users ID
emailStringThe users email
full_nameStringThe users full name
email_verifiedBooleanThe check to see if the user veritified their email
discord_usernameStringThe User’s Discord ID
beta_features_enabledBooleanThe toggle to enable beta features on an account
subscriptionStringThe check to see if the user has an active subscription

GET /auth/discord

/auth/discord is used to authroize Snapcaster’s services with the users personal discord account. The user is redirected to discord’s authentication WebTransportBidirectionalStream.

  1. HTTP 200 OK
  2. HTTP 401 Unauthorized: User not identified

GET /auth/discord/callback

/auth/discord/callback is handles changing the user’s pro membership role in the Snapcaster discord for things such as giveaways.

  1. Redirect to the user's profile page upon success
  2. HTTP 400 Bad Request | No code provided | No state provided | Invalid state token
  3. HTTP 500 Internal Server Errpr | An error occurred during Discord OAuth2 process

GET /auth/discord/disconnect

/auth/discord/disconnect removes the User’s discord from snapcaster’s private Discord services.

  1. HTTP 200 OK | Discord account disconnected
  2. HTTP 401 | Unauthorized: User not identified
  3. HTTP 500 Internal Server Errpr | Error disconnecting Discord account

POST /reset-password

The /reset-password uses a unique token generated from /forgot-password and allows a user to reset their password.

  1. HTTP 200 OK | Password reset successfully
  2. HTTP 400 Bad Request | Invalid token or Token expired

Forgot Password Parameters

ParameterTypeMandatoryDetails
passwordStringMandatoryThe users password
tokenStringMandatoryThe users temporary reset password token