Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,425 changes: 1,185 additions & 1,240 deletions server/package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@
"license": "ISC",
"devDependencies": {
"@eslint/js": "^9.32.0",
"@faker-js/faker": "^9.6.0",
"@faker-js/faker": "^10.2.0",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.2",
"@types/jsonwebtoken": "^9.0.6",
"@types/multer": "^1.4.11",
"@types/node": "^22.15.19",
"@types/multer": "^2.0.0",
"@types/node": "^25.2.0",
"@types/swagger-ui-express": "^4.1.6",
"csv-parse": "^5.5.5",
"csv-parse": "^6.1.0",
"eslint": "^9.32.0",
"nodemon": "^3.0.3",
"ts-node-dev": "^2.0.0",
"typescript": "^5.8.3",
"typescript-eslint": "^8.38.0"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/lib-storage": "^3.540.0",
"@sentry/cli": "^2.33.1",
"@sentry/node": "^9.20.0",
"@aws-sdk/client-s3": "^3.981.0",
"@aws-sdk/lib-storage": "^3.981.0",
"@sentry/cli": "^3.1.0",
"@sentry/node": "^10.38.0",
"@slack/bolt": "^4.4.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"docxtemplater": "^3.65.2",
"dotenv": "^16.4.1",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"helmet": "^8.1.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.1.1",
"mongoose": "^9.1.5",
"multer": "^2.0.0",
"pizzip": "^3.2.0",
"remove-accents": "^0.5.0",
Expand All @@ -58,4 +58,4 @@
"yaml": "^2.3.4",
"zod": "^4.0.10"
}
}
}
12 changes: 6 additions & 6 deletions server/src/controllers/Trainee/EmploymentHistoryController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class EmploymentHistoryController implements EmploymentHistoryControllerT

async getEmploymentHistory(req: Request, res: Response, next: NextFunction): Promise<void> {
try {
const traineeID = req.params.id;
const traineeID = String(req.params.id);
const employmentHistory = await this.traineesRepository.getEmploymentHistory(traineeID);
res.json(employmentHistory);
} catch (error: any) {
Expand All @@ -23,7 +23,7 @@ export class EmploymentHistoryController implements EmploymentHistoryControllerT
}

async addEmploymentHistory(req: Request, res: Response, next: NextFunction): Promise<void> {
const traineeID = req.params.id;
const traineeID = String(req.params.id);
const employmentHistoryData: EmploymentHistory = req.body;
try {
validateEmploymentHistory(employmentHistoryData);
Expand All @@ -41,14 +41,14 @@ export class EmploymentHistoryController implements EmploymentHistoryControllerT
}

async updateEmploymentHistory(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

const employmentHistoryData = trainee.employmentInfo.employmentHistory.find(
(history) => history.id === req.params.employmentHistoryID
(history) => history.id === String(req.params.employmentHistoryID)
);
if (!employmentHistoryData) {
res.status(404).send(new ResponseError('Employment history was not found'));
Expand Down Expand Up @@ -88,13 +88,13 @@ export class EmploymentHistoryController implements EmploymentHistoryControllerT

async deleteEmploymentHistory(req: Request, res: Response, next: NextFunction): Promise<void> {
try {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

const employmentHistoryID = req.params.employmentHistoryID;
const employmentHistoryID = String(req.params.employmentHistoryID);
if (!trainee.employmentInfo.employmentHistory.find((history) => history.id === employmentHistoryID)) {
res.status(404).send(new ResponseError('Employment history not found'));
return;
Expand Down
23 changes: 13 additions & 10 deletions server/src/controllers/Trainee/InteractionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class InteractionController implements InteractionControllerType {
) {}

async getInteractions(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -33,7 +33,7 @@ export class InteractionController implements InteractionControllerType {
}

async addInteraction(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -57,7 +57,7 @@ export class InteractionController implements InteractionControllerType {
}

try {
const interaction = await this.traineesRepository.addInteraction(req.params.id, newInteraction);
const interaction = await this.traineesRepository.addInteraction(String(req.params.id), newInteraction);
res.status(201).json(interaction);
this.notificationService.interactionCreated(trainee, interaction);
} catch (error: any) {
Expand All @@ -66,21 +66,21 @@ export class InteractionController implements InteractionControllerType {
}

async updateInteraction(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

const interaction = trainee.interactions.find((interaction) => interaction.id === req.params.interactionID);
const interaction = trainee.interactions.find((interaction) => interaction.id === String(req.params.interactionID));
if (!interaction) {
res.status(404).send(new ResponseError('Interaction not found'));
return;
}

const user = res.locals.user as AuthenticatedUser;
const interactionToUpdate: InteractionWithReporterID = {
id: req.params.interactionID,
id: String(req.params.interactionID),
date: req.body.date,
type: req.body.type,
title: req.body.title,
Expand All @@ -97,7 +97,10 @@ export class InteractionController implements InteractionControllerType {
}

try {
const updatedInteraction = await this.traineesRepository.updateInteraction(req.params.id, interactionToUpdate);
const updatedInteraction = await this.traineesRepository.updateInteraction(
String(req.params.id),
interactionToUpdate
);
res.status(200).json(updatedInteraction);
} catch (error: any) {
console.error(error);
Expand All @@ -107,19 +110,19 @@ export class InteractionController implements InteractionControllerType {
}

async deleteInteraction(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

if (!trainee.interactions.find((interaction) => interaction.id === req.params.interactionID)) {
if (!trainee.interactions.find((interaction) => interaction.id === String(req.params.interactionID))) {
res.status(404).send(new ResponseError('Interaction not found'));
return;
}

try {
await this.traineesRepository.deleteInteraction(req.params.id, req.params.interactionID);
await this.traineesRepository.deleteInteraction(String(req.params.id), String(req.params.interactionID));
res.status(204).end();
} catch (error: any) {
next(error);
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/Trainee/LetterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class LetterController implements LetterControllerType {

async generateLetter(req: Request, res: Response, next: NextFunction): Promise<void> {
const { type } = req.body as { type: LetterType };
const traineeID = req.params.id;
const traineeID = String(req.params.id);

const trainee = await this.traineeRepository.getTrainee(traineeID);
if (!trainee) {
Expand Down
4 changes: 2 additions & 2 deletions server/src/controllers/Trainee/ProfilePictureController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ProfilePictureController implements ProfilePictureControllerType {
}

async setProfilePicture(req: Request, res: Response, next: NextFunction) {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand Down Expand Up @@ -109,7 +109,7 @@ export class ProfilePictureController implements ProfilePictureControllerType {
}

async deleteProfilePicture(req: Request, res: Response, next: NextFunction) {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand Down
18 changes: 9 additions & 9 deletions server/src/controllers/Trainee/StrikeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class StrikeController implements StrikeControllerType {
) {}

async getStrikes(req: Request, res: Response, next: NextFunction) {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -35,7 +35,7 @@ export class StrikeController implements StrikeControllerType {
}

async addStrike(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -59,7 +59,7 @@ export class StrikeController implements StrikeControllerType {
}

try {
const strike = await this.traineesRepository.addStrike(req.params.id, newStrike);
const strike = await this.traineesRepository.addStrike(String(req.params.id), newStrike);
res.status(201).json(strike);
this.notificationService.strikeCreated(trainee, strike);
} catch (error: any) {
Expand All @@ -68,21 +68,21 @@ export class StrikeController implements StrikeControllerType {
}

async updateStrike(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

const strike = trainee.educationInfo.strikes.find((strike) => strike.id === req.params.strikeId);
const strike = trainee.educationInfo.strikes.find((strike) => strike.id === String(req.params.strikeId));
if (!strike) {
res.status(404).send(new ResponseError('Strike not found'));
return;
}

const user = res.locals.user as AuthenticatedUser;
const strikeToUpdate: StrikeWithReporterID = {
id: req.params.strikeId,
id: String(req.params.strikeId),
reason: req.body.reason,
date: req.body.date,
comments: req.body.comments,
Expand All @@ -98,7 +98,7 @@ export class StrikeController implements StrikeControllerType {
}

try {
const updatedStrike = await this.traineesRepository.updateStrike(req.params.id, strikeToUpdate);
const updatedStrike = await this.traineesRepository.updateStrike(String(req.params.id), strikeToUpdate);
res.status(200).json(updatedStrike);
} catch (error: any) {
next(error);
Expand All @@ -107,13 +107,13 @@ export class StrikeController implements StrikeControllerType {
}

async deleteStrike(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}
try {
await this.traineesRepository.deleteStrike(req.params.id, req.params.strikeId);
await this.traineesRepository.deleteStrike(String(req.params.id), String(req.params.strikeId));
res.status(204).end();
} catch (error: any) {
next(error);
Expand Down
16 changes: 8 additions & 8 deletions server/src/controllers/Trainee/TestController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class TestController implements TestControllerType {
) {}

async getTests(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -32,7 +32,7 @@ export class TestController implements TestControllerType {
}

async addTest(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand All @@ -58,20 +58,20 @@ export class TestController implements TestControllerType {
}

async updateTest(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

const test = trainee.educationInfo.tests.find((test) => test.id === req.params.testID);
const test = trainee.educationInfo.tests.find((test) => test.id === String(req.params.testID));
if (!test) {
res.status(404).send(new ResponseError('Test not found'));
return;
}

const testToUpdate: Test = {
id: req.params.testID,
id: String(req.params.testID),
date: req.body.date,
type: req.body.type,
result: req.body.result,
Expand All @@ -98,19 +98,19 @@ export class TestController implements TestControllerType {
}

async deleteTest(req: Request, res: Response, next: NextFunction): Promise<void> {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
}

if (!trainee.educationInfo.tests.find((test) => test.id === req.params.testID)) {
if (!trainee.educationInfo.tests.find((test) => test.id === String(req.params.testID))) {
res.status(404).send(new ResponseError('Test not found'));
return;
}

try {
await this.traineesRepository.deleteTest(req.params.id, req.params.testID);
await this.traineesRepository.deleteTest(String(req.params.id), String(req.params.testID));
res.status(204).end();
} catch (error: any) {
next(error);
Expand Down
4 changes: 2 additions & 2 deletions server/src/controllers/Trainee/TraineeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TraineeController implements TraineeControllerType {
) {}

async getTrainee(req: Request, res: Response, next: NextFunction) {
const traineeId = req.params.id;
const traineeId = String(req.params.id);
try {
const trainee = await this.traineesRepository.getTrainee(traineeId);
if (!trainee) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export class TraineeController implements TraineeControllerType {
}

async updateTrainee(req: Request, res: Response, next: NextFunction) {
const trainee = await this.traineesRepository.getTrainee(req.params.id);
const trainee = await this.traineesRepository.getTrainee(String(req.params.id));
if (!trainee) {
res.status(404).send(new ResponseError('Trainee not found'));
return;
Expand Down
4 changes: 2 additions & 2 deletions server/src/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class DefaultUserController implements UserController {
* 200 | 400 | 404 | 500
*/
async updateUser(req: Request, res: Response) {
const userId = req.params.id;
const userId = String(req.params.id);

//validate
const userUpdates = UpdateUserSchema.safeParse(req.body);
Expand Down Expand Up @@ -94,7 +94,7 @@ export class DefaultUserController implements UserController {
* 204 | 404 | 500
*/
async deleteUser(req: Request, res: Response) {
const userId = req.params.id;
const userId = String(req.params.id);

const deletedUser = await this.userRepository.deleteUser(userId);
if (!deletedUser) {
Expand Down