fix: .js toevoegen aan imports

This commit is contained in:
Tibo De Peuter 2025-04-24 10:53:08 +02:00
parent 6847961688
commit 04fd54e3d6
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
25 changed files with 73 additions and 75 deletions

View file

@ -2,10 +2,10 @@ import { UnauthorizedException } from '../exceptions/unauthorized-exception.js';
import { getLogger } from '../logging/initalize.js'; import { getLogger } from '../logging/initalize.js';
import { AuthenticatedRequest } from '../middleware/auth/authenticated-request.js'; import { AuthenticatedRequest } from '../middleware/auth/authenticated-request.js';
import { envVars, getEnvVar } from '../util/envVars.js'; import { envVars, getEnvVar } from '../util/envVars.js';
import { createOrUpdateStudent, createStudent } from '../services/students'; import { createOrUpdateStudent, createStudent } from '../services/students.js';
import { AuthenticationInfo } from '../middleware/auth/authentication-info'; import { AuthenticationInfo } from '../middleware/auth/authentication-info.js';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { createOrUpdateTeacher, createTeacher } from '../services/teachers'; import { createOrUpdateTeacher, createTeacher } from '../services/teachers.js';
interface FrontendIdpConfig { interface FrontendIdpConfig {
authority: string; authority: string;

View file

@ -2,7 +2,7 @@ import { Request, Response } from 'express';
import { requireFields } from './error-helper.js'; import { requireFields } from './error-helper.js';
import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations.js'; import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations.js';
import { TeacherInvitationData } from '@dwengo-1/common/interfaces/teacher-invitation'; import { TeacherInvitationData } from '@dwengo-1/common/interfaces/teacher-invitation';
import { ConflictException } from '../exceptions/conflict-exception'; import { ConflictException } from '../exceptions/conflict-exception.js';
export async function getAllInvitationsHandler(req: Request, res: Response): Promise<void> { export async function getAllInvitationsHandler(req: Request, res: Response): Promise<void> {
const username = req.params.username; const username = req.params.username;

View file

@ -1,7 +1,7 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { fetchClass } from '../../../services/classes'; import { fetchClass } from '../../../services/classes.js';
import { fetchAllGroups } from '../../../services/groups'; import { fetchAllGroups } from '../../../services/groups.js';
import { mapToUsername } from '../../../interfaces/user'; import { mapToUsername } from '../../../interfaces/user.js';
/** /**
* Expects the path to contain the path parameters 'classId' and 'id' (meaning the ID of the assignment). * Expects the path to contain the path parameters 'classId' and 'id' (meaning the ID of the assignment).

View file

@ -1,9 +1,9 @@
import { AuthenticationInfo } from '../authentication-info'; import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request'; import { AuthenticatedRequest } from '../authenticated-request.js';
import * as express from 'express'; import * as express from 'express';
import { UnauthorizedException } from '../../../exceptions/unauthorized-exception';
import { ForbiddenException } from '../../../exceptions/forbidden-exception';
import { RequestHandler } from 'express'; import { RequestHandler } from 'express';
import { UnauthorizedException } from '../../../exceptions/unauthorized-exception.js';
import { ForbiddenException } from '../../../exceptions/forbidden-exception.js';
/** /**
* Middleware which rejects unauthenticated users (with HTTP 401) and authenticated users which do not fulfill * Middleware which rejects unauthenticated users (with HTTP 401) and authenticated users which do not fulfill

View file

@ -1,8 +1,8 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { AuthenticationInfo } from '../authentication-info'; import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request'; import { AuthenticatedRequest } from '../authenticated-request.js';
import { fetchClass } from '../../../services/classes'; import { fetchClass } from '../../../services/classes.js';
import { mapToUsername } from '../../../interfaces/user'; import { mapToUsername } from '../../../interfaces/user.js';
async function teaches(teacherUsername: string, classId: string): Promise<boolean> { async function teaches(teacherUsername: string, classId: string): Promise<boolean> {
const clazz = await fetchClass(classId); const clazz = await fetchClass(classId);

View file

@ -1,7 +1,7 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { fetchClass } from '../../../services/classes'; import { fetchClass } from '../../../services/classes.js';
import { fetchGroup } from '../../../services/groups'; import { fetchGroup } from '../../../services/groups.js';
import { mapToUsername } from '../../../interfaces/user'; import { mapToUsername } from '../../../interfaces/user.js';
/** /**
* Expects the path to contain the path parameters 'classid', 'assignmentid' and 'groupid'. * Expects the path to contain the path parameters 'classid', 'assignmentid' and 'groupid'.

View file

@ -1,12 +1,12 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { AuthenticationInfo } from '../authentication-info'; import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request'; import { AuthenticatedRequest } from '../authenticated-request.js';
import { requireFields } from '../../../controllers/error-helper'; import { requireFields } from '../../../controllers/error-helper.js';
import { getLearningObjectId, getQuestionId } from '../../../controllers/questions'; import { getLearningObjectId, getQuestionId } from '../../../controllers/questions.js';
import { fetchQuestion } from '../../../services/questions'; import { fetchQuestion } from '../../../services/questions.js';
import { FALLBACK_SEQ_NUM } from '../../../config'; import { FALLBACK_SEQ_NUM } from '../../../config.js';
import { fetchAnswer } from '../../../services/answers'; import { fetchAnswer } from '../../../services/answers.js';
import { mapToUsername } from '../../../interfaces/user'; import { mapToUsername } from '../../../interfaces/user.js';
export const onlyAllowAuthor = authorize( export const onlyAllowAuthor = authorize(
(auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { author: string }).author === auth.username (auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { author: string }).author === auth.username

View file

@ -1,11 +1,11 @@
import { LearningObjectIdentifier } from '../../../entities/content/learning-object-identifier';
import { fetchSubmission } from '../../../services/submissions';
import { AuthenticatedRequest } from '../authenticated-request';
import { AuthenticationInfo } from '../authentication-info';
import { authorize } from './auth-checks';
import { FALLBACK_LANG } from '../../../config';
import { mapToUsername } from '../../../interfaces/user';
import { languageMap } from '@dwengo-1/common/util/language'; import { languageMap } from '@dwengo-1/common/util/language';
import { LearningObjectIdentifier } from '../../../entities/content/learning-object-identifier.js';
import { fetchSubmission } from '../../../services/submissions.js';
import { AuthenticatedRequest } from '../authenticated-request.js';
import { AuthenticationInfo } from '../authentication-info.js';
import { authorize } from './auth-checks.js';
import { FALLBACK_LANG } from '../../../config.js';
import { mapToUsername } from '../../../interfaces/user.js';
export const onlyAllowSubmitter = authorize( export const onlyAllowSubmitter = authorize(
(auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { submitter: string }).submitter === auth.username (auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { submitter: string }).submitter === auth.username

View file

@ -1,6 +1,6 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { AuthenticationInfo } from '../authentication-info'; import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request'; import { AuthenticatedRequest } from '../authenticated-request.js';
export const onlyAllowSenderOrReceiver = authorize( export const onlyAllowSenderOrReceiver = authorize(
(auth: AuthenticationInfo, req: AuthenticatedRequest) => req.params.sender === auth.username || req.params.receiver === auth.username (auth: AuthenticationInfo, req: AuthenticatedRequest) => req.params.sender === auth.username || req.params.receiver === auth.username

View file

@ -1,6 +1,6 @@
import { authorize } from './auth-checks'; import { authorize } from './auth-checks.js';
import { AuthenticationInfo } from '../authentication-info'; import { AuthenticationInfo } from '../authentication-info.js';
import { AuthenticatedRequest } from '../authenticated-request'; import { AuthenticatedRequest } from '../authenticated-request.js';
/** /**
* Only allow the user whose username is in the path parameter "username" to access the endpoint. * Only allow the user whose username is in the path parameter "username" to access the endpoint.

View file

@ -1,7 +1,7 @@
import express from 'express'; import express from 'express';
import { createAnswerHandler, deleteAnswerHandler, getAnswerHandler, getAllAnswersHandler, updateAnswerHandler } from '../controllers/answers.js'; import { createAnswerHandler, deleteAnswerHandler, getAnswerHandler, getAllAnswersHandler, updateAnswerHandler } from '../controllers/answers.js';
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks'; import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowAuthor, onlyAllowAuthorRequestAnswer, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks'; import { onlyAllowAuthor, onlyAllowAuthorRequestAnswer, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
const router = express.Router({ mergeParams: true }); const router = express.Router({ mergeParams: true });

View file

@ -9,9 +9,9 @@ import {
putAssignmentHandler, putAssignmentHandler,
} from '../controllers/assignments.js'; } from '../controllers/assignments.js';
import groupRouter from './groups.js'; import groupRouter from './groups.js';
import { teachersOnly } from '../middleware/auth/checks/auth-checks'; import { teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks'; import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks.js';
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks'; import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks.js';
const router = express.Router({ mergeParams: true }); const router = express.Router({ mergeParams: true });

View file

@ -14,8 +14,8 @@ import {
putClassHandler, putClassHandler,
} from '../controllers/classes.js'; } from '../controllers/classes.js';
import assignmentRouter from './assignments.js'; import assignmentRouter from './assignments.js';
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks'; import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks'; import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks.js';
const router = express.Router(); const router = express.Router();

View file

@ -8,9 +8,9 @@ import {
getGroupSubmissionsHandler, getGroupSubmissionsHandler,
putGroupHandler, putGroupHandler,
} from '../controllers/groups.js'; } from '../controllers/groups.js';
import { onlyAllowIfHasAccessToGroup } from '../middleware/auth/checks/group-auth-checker'; import { onlyAllowIfHasAccessToGroup } from '../middleware/auth/checks/group-auth-checker.js';
import { teachersOnly } from '../middleware/auth/checks/auth-checks'; import { teachersOnly } from '../middleware/auth/checks/auth-checks.js';
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks'; import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks.js';
const router = express.Router({ mergeParams: true }); const router = express.Router({ mergeParams: true });

View file

@ -1,9 +1,8 @@
import express from 'express'; import express from 'express';
import { getAllLearningObjects, getAttachment, getLearningObject, getLearningObjectHTML } from '../controllers/learning-objects.js'; import { getAllLearningObjects, getAttachment, getLearningObject, getLearningObjectHTML } from '../controllers/learning-objects.js';
import submissionRoutes from './submissions.js'; import submissionRoutes from './submissions.js';
import questionRoutes from './questions.js'; import questionRoutes from './questions.js';
import { authenticatedOnly } from '../middleware/auth/checks/auth-checks'; import { authenticatedOnly } from '../middleware/auth/checks/auth-checks.js';
const router = express.Router(); const router = express.Router();

View file

@ -1,6 +1,6 @@
import express from 'express'; import express from 'express';
import { getLearningPaths } from '../controllers/learning-paths.js'; import { getLearningPaths } from '../controllers/learning-paths.js';
import { authenticatedOnly } from '../middleware/auth/checks/auth-checks'; import { authenticatedOnly } from '../middleware/auth/checks/auth-checks.js';
const router = express.Router(); const router = express.Router();

View file

@ -1,9 +1,9 @@
import express from 'express'; import express from 'express';
import { createQuestionHandler, deleteQuestionHandler, getAllQuestionsHandler, getQuestionHandler } from '../controllers/questions.js'; import { createQuestionHandler, deleteQuestionHandler, getAllQuestionsHandler, getQuestionHandler } from '../controllers/questions.js';
import answerRoutes from './answers.js'; import answerRoutes from './answers.js';
import { adminOnly, studentsOnly } from '../middleware/auth/checks/auth-checks'; import { adminOnly, studentsOnly } from '../middleware/auth/checks/auth-checks.js';
import { updateAnswerHandler } from '../controllers/answers'; import { updateAnswerHandler } from '../controllers/answers.js';
import { onlyAllowAuthor, onlyAllowAuthorRequest, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks'; import { onlyAllowAuthor, onlyAllowAuthorRequest, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
const router = express.Router({ mergeParams: true }); const router = express.Router({ mergeParams: true });

View file

@ -5,8 +5,8 @@ import {
getStudentRequestHandler, getStudentRequestHandler,
getStudentRequestsHandler, getStudentRequestsHandler,
} from '../controllers/students.js'; } from '../controllers/students.js';
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks'; import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
import { onlyAllowStudentHimselfAndTeachersOfClass } from '../middleware/auth/checks/class-auth-checks'; import { onlyAllowStudentHimselfAndTeachersOfClass } from '../middleware/auth/checks/class-auth-checks.js';
// Under /:username/joinRequests/ // Under /:username/joinRequests/

View file

@ -11,8 +11,8 @@ import {
getStudentSubmissionsHandler, getStudentSubmissionsHandler,
} from '../controllers/students.js'; } from '../controllers/students.js';
import joinRequestRouter from './student-join-requests.js'; import joinRequestRouter from './student-join-requests.js';
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks'; import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
import { adminOnly } from '../middleware/auth/checks/auth-checks'; import { adminOnly } from '../middleware/auth/checks/auth-checks.js';
const router = express.Router(); const router = express.Router();

View file

@ -5,14 +5,14 @@ import {
getAllInvitationsHandler, getAllInvitationsHandler,
getInvitationHandler, getInvitationHandler,
updateInvitationHandler, updateInvitationHandler,
} from '../controllers/teacher-invitations'; } from '../controllers/teacher-invitations.js';
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks'; import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
import { import {
onlyAllowReceiverBody, onlyAllowReceiverBody,
onlyAllowSender, onlyAllowSender,
onlyAllowSenderBody, onlyAllowSenderBody,
onlyAllowSenderOrReceiver, onlyAllowSenderOrReceiver,
} from '../middleware/auth/checks/teacher-invitation-checks'; } from '../middleware/auth/checks/teacher-invitation-checks.js';
const router = express.Router({ mergeParams: true }); const router = express.Router({ mergeParams: true });

View file

@ -11,10 +11,9 @@ import {
updateStudentJoinRequestHandler, updateStudentJoinRequestHandler,
} from '../controllers/teachers.js'; } from '../controllers/teachers.js';
import invitationRouter from './teacher-invitations.js'; import invitationRouter from './teacher-invitations.js';
import { adminOnly } from '../middleware/auth/checks/auth-checks.js';
import { adminOnly } from '../middleware/auth/checks/auth-checks'; import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks'; import { onlyAllowTeacherOfClass } from '../middleware/auth/checks/class-auth-checks.js';
import { onlyAllowTeacherOfClass } from '../middleware/auth/checks/class-auth-checks';
const router = express.Router(); const router = express.Router();
// Root endpoint used to search objects // Root endpoint used to search objects

View file

@ -1,6 +1,6 @@
import express from 'express'; import express from 'express';
import { getThemesHandler, getHruidsByThemeHandler } from '../controllers/themes.js'; import { getThemesHandler, getHruidsByThemeHandler } from '../controllers/themes.js';
import { authenticatedOnly } from '../middleware/auth/checks/auth-checks'; import { authenticatedOnly } from '../middleware/auth/checks/auth-checks.js';
const router = express.Router(); const router = express.Router();

View file

@ -12,7 +12,7 @@ import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment';
import { fetchStudent } from './students.js'; import { fetchStudent } from './students.js';
import { NotFoundException } from '../exceptions/not-found-exception.js'; import { NotFoundException } from '../exceptions/not-found-exception.js';
import { FALLBACK_VERSION_NUM } from '../config.js'; import { FALLBACK_VERSION_NUM } from '../config.js';
import { ConflictException } from '../exceptions/conflict-exception'; import { ConflictException } from '../exceptions/conflict-exception.js';
export async function getQuestionsAboutLearningObjectInAssignment( export async function getQuestionsAboutLearningObjectInAssignment(
loId: LearningObjectIdentifier, loId: LearningObjectIdentifier,

View file

@ -24,8 +24,8 @@ import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/subm
import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request';
import { ConflictException } from '../exceptions/conflict-exception.js'; import { ConflictException } from '../exceptions/conflict-exception.js';
import { Submission } from '../entities/assignments/submission.entity'; import { Submission } from '../entities/assignments/submission.entity.js';
import { mapToUsername } from '../interfaces/user'; import { mapToUsername } from '../interfaces/user.js';
export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> { export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> {
const studentRepository = getStudentRepository(); const studentRepository = getStudentRepository();

View file

@ -30,7 +30,7 @@ import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request';
import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; import { ClassStatus } from '@dwengo-1/common/util/class-join-request';
import { ConflictException } from '../exceptions/conflict-exception.js'; import { ConflictException } from '../exceptions/conflict-exception.js';
import { mapToUsername } from '../interfaces/user'; import { mapToUsername } from '../interfaces/user.js';
export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> { export async function getAllTeachers(full: boolean): Promise<TeacherDTO[] | string[]> {
const teacherRepository: TeacherRepository = getTeacherRepository(); const teacherRepository: TeacherRepository = getTeacherRepository();