-
Notifications
You must be signed in to change notification settings - Fork 0
Server
The Server part of the project is made using SvelteKit, a JavaScript framework made to simplify all server actions (fetch, http protocol, ...) and related to Svelte framework.
The project data is stored only in a AWS cluster using Vercel, a deployer and web-app maintainer. The database is written in SQL using PostgreSQL framework.
The following is a representation of our database schemas :
model User {
id Int @id @unique @default(autoincrement())
email String @unique
role UserRole @default(USER)
token String @unique
hashedPassword String
createdAt DateTime @default(now())
username String @unique
Service Service[]
Program Program[]
}
model Program {
id Int @id @unique @default(autoincrement())
name String
actions Action[]
User User? @relation(fields: [userId], references: [id])
userId Int?
}
model Action {
id Int @id @unique @default(autoincrement())
programId Int?
actionId String
metadata Json?
persistentData Json?
program Program? @relation(fields: [programId], references: [id])
reactions Reaction[]
}
model Reaction {
id Int @id @unique @default(autoincrement())
reactionId String
actionId Int?
metadata Json?
persistentData Json?
action Action? @relation(fields: [actionId], references: [id])
}
model Service {
id Int @id @unique @default(autoincrement())
userId Int?
metadata Json
providerType Provider
User User? @relation(fields: [userId], references: [id])
}
enum UserRole {
USER
API_USER
ADMIN
}
enum Provider {
DISCORD
STEAM
SPOTIFY
BATTLENET
REDDIT
TWITCH
}The API routes are located in /api route. All the API routes are protected using JWT session checking.
This route is made to list all current implemented services, their actions and related reactions. As of this moment, the route is currently templated and not working dynamically with our database.
This route is made to encapsulate all the authentication methods for the API user.
-
POST /api/auth/login: Login the user using JWT encryption.- Required body: (JSON)
{ "email": "string", "password": "string" }
- Required body: (JSON)
-
POST /api/auth/register: Register the user using JWT encryption.- Required body: (JSON)
{ "email": "string", "password": "string", "username": "string", "role": "USER" }
- Required body: (JSON)
-
GET /api/auth/logout: Logout the user. (deletes their token)- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers:
-
GET /api/user: Get the user data.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers:
-
POST /api/user: Update the user data.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "email": "string", "password": "string", "username": "string" }
- Required headers:
This route is made to encapsulate service routes to link the latter to the user.
The routes architecture are the following : /api/link/{service_name}
Services that are available include:
- Spotify
- Discord
- Steam
- BattleNet
- Twitch
This route is the same as Service Linking but used to unlink services.
This route is made to encapsulate all the program routes for the user.
-
GET /api/program: Get all the programs of the user.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers:
-
POST /api/program: Create a new program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "name": "string" }
- Required headers:
-
DELETE /api/program/{program_id}: Delete a program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers:
-
PATCH /api/program/{program_id}: Update a program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "name": "string" }
- Required headers:
-
PUT /api/program/{program_id}/node: Add a node to a program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "isAction || isReaction": "boolean (true)", "id || reactionId": "number", "metadata": "JSON" }
- Required headers:
-
DELETE /api/program/{program_id}/node: Delete a node from a program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "isAction || isReaction": "boolean (true)", "id": "number" }
- Required headers:
-
PATCH /api/program/{program_id}/node: Update a node from a program.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required body: (JSON)
{ "isAction || isReaction": "boolean (true)", "id": "number", "metadata": "JSON" }
- Required headers:
This route is made to list all the available actions for the user.
-
GET /api/actions: Get all the actions.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers:
This route is made to list all the available reactions for the user.
-
GET /api/reactions: Get all the reactions.- Required headers:
- Authorization:
Bearer <token>
- Authorization:
- Required headers: