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.
HTTP 200 OK
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.
HTTP 200 OK | [register object]
HTTP 400 Bad Request | User already exists
HTTP 500 Internal Server Error | Error registering user
Register Object
Property | Type | Details |
---|---|---|
String | The users email | |
fullName | String | The users first name and last name |
id | Integer | The users ID |
Register Parameters
Parameter | Type | Mandatory | Details |
---|---|---|---|
String | Mandatory | The users email | |
fullName | String | Mandatory | The users first and last name |
password | String | Mandatory | The users password |
POST /login
The /login
endpoint logs the user in and creates a user session.
HTTP 200 OK
HTTP 401 Unauthorized | Error logging in: [error]
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.
HTTP 200 OK | Password reset email sent
Forgot Password Parameters
Parameter | Type | Mandatory | Details |
---|---|---|---|
String | Mandatory | The 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.
HTTP 200 OK | [Update User object]
HTTP 401 Unauthorized | Unauthorized: User not identified
HTTP 404 Not Found | User not found
HTTP 500 Internal Server Errpr | Error updating user
Update User Object
Property | Type | Details |
---|---|---|
beta_features_enabled | Boolean | The toggle to enable beta features on an account |
String | The users email | |
full_name | String | The users full name |
id | Integer | The users ID |
Update User Parameters
Parameter | Type | Mandatory | Details |
---|---|---|---|
betaFeaturesEnabled | Boolean | Mandatory | The 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.
HTTP 200 OK | [Profile Object]
HTTP 401 Unauthorized | Unauthorized: User not identified
HTTP 404 Not Found | User not found
HTTP 500 Internal Server Errpr | Error updating user
Profile Object
Property | Type | Details |
---|---|---|
id | Integer | The users ID |
String | The users email | |
full_name | String | The users full name |
email_verified | Boolean | The check to see if the user veritified their email |
discord_username | String | The User’s Discord ID |
beta_features_enabled | Boolean | The toggle to enable beta features on an account |
subscription | String | The 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.
HTTP 200 OK
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.
Redirect to the user's profile page upon success
HTTP 400 Bad Request | No code provided | No state provided | Invalid state token
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.
HTTP 200 OK | Discord account disconnected
HTTP 401 | Unauthorized: User not identified
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.
HTTP 200 OK | Password reset successfully
HTTP 400 Bad Request | Invalid token or Token expired
Forgot Password Parameters
Parameter | Type | Mandatory | Details |
---|---|---|---|
password | String | Mandatory | The users password |
token | String | Mandatory | The users temporary reset password token |