# First, make sure you are in the `backend` directory
npm installcp .env.example .envAdd the secrets to the .env file. You may be provided a .env file externally.
npm run watchThis will start the server and watch for changes to the TypeScript files. The server will automatically restart when changes are detected.
The entrypoint for the server is src/app.ts. This file is responsible for setting up the server and routes.
The folder structure is as follows:
.
├── src
│ ├── controllers
│ ├── db
│ ├── middleware
│ ├── routes
│ ├── services
│ ├── test
│ ├── utils
│ ├── app.ts
├── var
│ ├── db
│ ├── sessions.db
├── users.db
├── .env
- app.ts: The entrypoint for the server. This file sets up the server and routes.
app.ts"uses" routes defined in theroutesfolder. - routes: This folder contains all the routes for the server (such as the endpoint "/endpoint" and whether it is a GET or POST request). The files in this folder "use" controllers defined in the
controllersfolder. - controllers: This folder contains the logic for the routes. The files in this folder "use" services defined in the
servicesfolder. - services: This folder contains the logic for the controllers. The files in this folder "use" the database defined in the
dbfolder. - db: This folder contains the database logic.
- utils: This folder contains utility functions used across the server.
- middleware: (Not important) This folder contains middleware functions used across the server.
The API documentation is available at /api-docs endpoint. Also, the API documentation is available at Swagger UI.
Version 1.0
| Method | Path | Description |
|---|---|---|
| GET | /loggedIn | Check if the user is logged in by checking if the connect.sid cookie is present and valid |
| POST | /logout | Log the user session out |
| POST | /auth/one-tap/callback | A callback endpoint for Google OAuth |
| POST | /auth/basic/callback | A callback endpoint for Basic Authentication |
| GET | /getAccountDetails | Gets the user related information to show in My Account |
| POST | /saveAccountDetails | Save the user related information shown in My Account |
| GET | /arrConfigs | Returns an of all available ARR configs |
| GET | /subjects | Returns an array of all subjects |
| GET | /courses | Returns an array of all courses for subjectId |
| GET | /semesterStrings | Returns an array of all semester strings objects |
| GET | /gradeOptions | Returns an array of all grade options |
| GET | /userCourse | Returns an array of user courses |
| POST | /userCourse | Add a user course |
| DELETE | /userCourse | Delete a user course |
| GET | /userAssignment | Returns an array of user course assignments |
| POST | /userAssignment | Add a user course assignment |
| PUT | /userAssignment | Put all user course assignments |
| DELETE | /userAssignment | Delete a user course assignment |
| PUT | /userSelectedArrConfig | Save the user selected ARR Configs |
| GET | /userSelectedArrConfig | Get the user selected ARR Configs |
| Name | Path | Description |
|---|---|---|
| UserSelectedArrConfigs | #/components/schemas/UserSelectedArrConfigs | |
| DegreeRequirementAssignment | #/components/schemas/DegreeRequirementAssignment | |
| UserCourse | #/components/schemas/UserCourse | |
| Subject | #/components/schemas/Subject | |
| Section | #/components/schemas/Section | |
| Subsection | #/components/schemas/Subsection | |
| FixedRequirement | #/components/schemas/FixedRequirement | |
| PrefixRequirement | #/components/schemas/PrefixRequirement | |
| AnonymousRequirement | #/components/schemas/AnonymousRequirement | |
| Course | #/components/schemas/Course | |
| Account | #/components/schemas/Account | |
| SuccessMessage | #/components/schemas/SuccessMessage | |
| FailureMessage | #/components/schemas/FailureMessage | |
| AuthSuccess | #/components/schemas/AuthSuccess | |
| AuthFailure | #/components/schemas/AuthFailure | |
| UserAuth | #/components/schemas/UserAuth | |
| cookieAuth | #/components/securitySchemes/cookieAuth |
- Summary
Check if the user is logged in by checking if the connect.sid cookie is present and valid
- 200 Returns an object with a message as "sucesss" or "fail"
application/json
{
"oneOf": [
{
"$ref": "#/components/schemas/AuthSuccess"
},
{
"$ref": "#/components/schemas/AuthFailure"
}
]
}- Summary
Log the user session out
- 200 success
application/json
{
message?: string
}- Summary
A callback endpoint for Google OAuth
- application/json
{
credential?: string
}- 200 The session ID is returned in a cookie named
connect.sid. You need to include this cookie in subsequent requests.
application/json
{
id?: string
email?: string
name?: string
}- Summary
A callback endpoint for Basic Authentication
- application/json
{
credential?: string
}- 200 The session ID is returned in a cookie named
connect.sid. You need to include this cookie in subsequent requests.
application/json
{
id?: string
email?: string
name?: string
}-
Summary
Gets the user related information to show in My Account -
Security
cookieAuth
- 200 Account info
application/json
{
email?: string
majors?: string[]
gradSem?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Save the user related information shown in My Account -
Security
cookieAuth
- application/json
{
email?: string
majors?: string[]
gradSem?: string
}- 200 Saved successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}- Summary
Returns an of all available ARR configs
- 200 An array of all available ARR configs
application/json
{
id?: string
title?: string
description?: string
subsections: {
title?: string
description?: string
requirements?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement[]
}[]
}[]- Summary
Returns an array of all subjects
- 200 array of all subjects
application/json
{
id?: string
short?: string
long?: string
title?: string
}[]- Summary
Returns an array of all courses forsubjectId
subjectId: string- 200 Returns an array of all courses for
subjectId
application/json
{
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}[]- 400 Bad Request
application/json
{
message?: string
error?: string
}- Summary
Returns an array of all semester strings objects
- 200 an array of all semester strings
application/json
{
display?: string
value?: string
}[]- Summary
Returns an array of all grade options
- 200 an array of grade options
application/json
string[]-
Summary
Returns an array of user courses -
Security
cookieAuth
- 200 an array of user courses
application/json
{
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}[]- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Add a user course -
Security
cookieAuth
- application/json
{
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}- 200 Added successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Delete a user course -
Security
cookieAuth
courseId: string- 200 Deleted successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Returns an array of user course assignments -
Security
cookieAuth
- 200 an array of user course assignments
application/json
{
status?: string
id?: string
requirement?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement
userCourse: {
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}
}[]- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Add a user course assignment -
Security
cookieAuth
- application/json
{
status?: string
id?: string
requirement?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement
userCourse: {
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}
}- 200 Added successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Put all user course assignments -
Security
cookieAuth
- application/json
{
status?: string
id?: string
requirement?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement
userCourse: {
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}
}[]- 200 Added successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Delete a user course assignment -
Security
cookieAuth
assignmentId: string- 200 Deleted successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Save the user selected ARR Configs -
Security
cookieAuth
- application/json
string[]- 200 Added successfully
application/json
{
message?: string
}- 400 Bad Request
application/json
{
message?: string
error?: string
}- 401 Unauthorized
application/json
{
message?: string
error?: string
}-
Summary
Get the user selected ARR Configs -
Security
cookieAuth
- 200 Array of user selected ARR Config ids
application/json
string[]- 401 Unauthorized
application/json
{
message?: string
error?: string
}string[]{
status?: string
id?: string
requirement?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement
userCourse: {
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}
}{
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
semester?: string
transferred?: boolean
grade?: string
professor?: string
notes?: string
creditsAwarded?: string
}{
id?: string
short?: string
long?: string
title?: string
}{
id?: string
title?: string
description?: string
subsections: {
title?: string
description?: string
requirements?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement[]
}[]
}{
title?: string
description?: string
requirements?: #/components/schemas/FixedRequirement | #/components/schemas/PrefixRequirement | #/components/schemas/AnonymousRequirement[]
}{
requirementType?: string
course: {
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}
}{
requirementType?: string
requirementId?: string
subjectId?: string
prefix?: string
description?: string
credits?: string
}{
requirementType?: string
designation?: string
description?: string
credits?: string
}{
id?: string
subjectId?: string
number?: string
title?: string
displayTitle?: string
credits?: string
titleLong?: string
subjectLong?: string
subjectShort?: string
topic?: string
description?: string
hasTopics?: boolean
corequisites?: string
prerequisites?: string
hasRestrictions?: boolean
}{
email?: string
majors?: string[]
gradSem?: string
}{
message?: string
}{
message?: string
error?: string
}{
message?: string
user: {
id?: string
email?: string
name?: string
}
}{
message?: string
}{
id?: string
email?: string
name?: string
}{
"type": "apiKey",
"in": "cookie",
"name": "connect.sid"
}Based on TypeScript Node Starter and Express Generator
