fix: .js toevoegen aan imports
This commit is contained in:
parent
6847961688
commit
04fd54e3d6
25 changed files with 73 additions and 75 deletions
|
@ -2,10 +2,10 @@ import { UnauthorizedException } from '../exceptions/unauthorized-exception.js';
|
|||
import { getLogger } from '../logging/initalize.js';
|
||||
import { AuthenticatedRequest } from '../middleware/auth/authenticated-request.js';
|
||||
import { envVars, getEnvVar } from '../util/envVars.js';
|
||||
import { createOrUpdateStudent, createStudent } from '../services/students';
|
||||
import { AuthenticationInfo } from '../middleware/auth/authentication-info';
|
||||
import { createOrUpdateStudent, createStudent } from '../services/students.js';
|
||||
import { AuthenticationInfo } from '../middleware/auth/authentication-info.js';
|
||||
import { Request, Response } from 'express';
|
||||
import { createOrUpdateTeacher, createTeacher } from '../services/teachers';
|
||||
import { createOrUpdateTeacher, createTeacher } from '../services/teachers.js';
|
||||
|
||||
interface FrontendIdpConfig {
|
||||
authority: string;
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Request, Response } from 'express';
|
|||
import { requireFields } from './error-helper.js';
|
||||
import { createInvitation, deleteInvitation, getAllInvitations, getInvitation, updateInvitation } from '../services/teacher-invitations.js';
|
||||
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> {
|
||||
const username = req.params.username;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { fetchClass } from '../../../services/classes';
|
||||
import { fetchAllGroups } from '../../../services/groups';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { fetchClass } from '../../../services/classes.js';
|
||||
import { fetchAllGroups } from '../../../services/groups.js';
|
||||
import { mapToUsername } from '../../../interfaces/user.js';
|
||||
|
||||
/**
|
||||
* Expects the path to contain the path parameters 'classId' and 'id' (meaning the ID of the assignment).
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { AuthenticationInfo } from '../authentication-info.js';
|
||||
import { AuthenticatedRequest } from '../authenticated-request.js';
|
||||
import * as express from 'express';
|
||||
import { UnauthorizedException } from '../../../exceptions/unauthorized-exception';
|
||||
import { ForbiddenException } from '../../../exceptions/forbidden-exception';
|
||||
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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { fetchClass } from '../../../services/classes';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { AuthenticationInfo } from '../authentication-info.js';
|
||||
import { AuthenticatedRequest } from '../authenticated-request.js';
|
||||
import { fetchClass } from '../../../services/classes.js';
|
||||
import { mapToUsername } from '../../../interfaces/user.js';
|
||||
|
||||
async function teaches(teacherUsername: string, classId: string): Promise<boolean> {
|
||||
const clazz = await fetchClass(classId);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { fetchClass } from '../../../services/classes';
|
||||
import { fetchGroup } from '../../../services/groups';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { fetchClass } from '../../../services/classes.js';
|
||||
import { fetchGroup } from '../../../services/groups.js';
|
||||
import { mapToUsername } from '../../../interfaces/user.js';
|
||||
|
||||
/**
|
||||
* Expects the path to contain the path parameters 'classid', 'assignmentid' and 'groupid'.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { requireFields } from '../../../controllers/error-helper';
|
||||
import { getLearningObjectId, getQuestionId } from '../../../controllers/questions';
|
||||
import { fetchQuestion } from '../../../services/questions';
|
||||
import { FALLBACK_SEQ_NUM } from '../../../config';
|
||||
import { fetchAnswer } from '../../../services/answers';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { AuthenticationInfo } from '../authentication-info.js';
|
||||
import { AuthenticatedRequest } from '../authenticated-request.js';
|
||||
import { requireFields } from '../../../controllers/error-helper.js';
|
||||
import { getLearningObjectId, getQuestionId } from '../../../controllers/questions.js';
|
||||
import { fetchQuestion } from '../../../services/questions.js';
|
||||
import { FALLBACK_SEQ_NUM } from '../../../config.js';
|
||||
import { fetchAnswer } from '../../../services/answers.js';
|
||||
import { mapToUsername } from '../../../interfaces/user.js';
|
||||
|
||||
export const onlyAllowAuthor = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { author: string }).author === auth.username
|
||||
|
|
|
@ -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 { 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(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { submitter: string }).submitter === auth.username
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { AuthenticationInfo } from '../authentication-info.js';
|
||||
import { AuthenticatedRequest } from '../authenticated-request.js';
|
||||
|
||||
export const onlyAllowSenderOrReceiver = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) => req.params.sender === auth.username || req.params.receiver === auth.username
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { authorize } from './auth-checks';
|
||||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { authorize } from './auth-checks.js';
|
||||
import { AuthenticationInfo } from '../authentication-info.js';
|
||||
import { AuthenticatedRequest } from '../authenticated-request.js';
|
||||
|
||||
/**
|
||||
* Only allow the user whose username is in the path parameter "username" to access the endpoint.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import express from 'express';
|
||||
import { createAnswerHandler, deleteAnswerHandler, getAnswerHandler, getAllAnswersHandler, updateAnswerHandler } from '../controllers/answers.js';
|
||||
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowAuthor, onlyAllowAuthorRequestAnswer, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks';
|
||||
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { onlyAllowAuthor, onlyAllowAuthorRequestAnswer, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
|
||||
|
||||
const router = express.Router({ mergeParams: true });
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import {
|
|||
putAssignmentHandler,
|
||||
} from '../controllers/assignments.js';
|
||||
import groupRouter from './groups.js';
|
||||
import { teachersOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks';
|
||||
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks';
|
||||
import { teachersOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks.js';
|
||||
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks.js';
|
||||
|
||||
const router = express.Router({ mergeParams: true });
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ import {
|
|||
putClassHandler,
|
||||
} from '../controllers/classes.js';
|
||||
import assignmentRouter from './assignments.js';
|
||||
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks';
|
||||
import { adminOnly, teachersOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { onlyAllowIfInClass } from '../middleware/auth/checks/class-auth-checks.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import {
|
|||
getGroupSubmissionsHandler,
|
||||
putGroupHandler,
|
||||
} from '../controllers/groups.js';
|
||||
import { onlyAllowIfHasAccessToGroup } from '../middleware/auth/checks/group-auth-checker';
|
||||
import { teachersOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks';
|
||||
import { onlyAllowIfHasAccessToGroup } from '../middleware/auth/checks/group-auth-checker.js';
|
||||
import { teachersOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { onlyAllowIfHasAccessToAssignment } from '../middleware/auth/checks/assignment-auth-checks.js';
|
||||
|
||||
const router = express.Router({ mergeParams: true });
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import express from 'express';
|
||||
import { getAllLearningObjects, getAttachment, getLearningObject, getLearningObjectHTML } from '../controllers/learning-objects.js';
|
||||
|
||||
import submissionRoutes from './submissions.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();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import express from 'express';
|
||||
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();
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import express from 'express';
|
||||
import { createQuestionHandler, deleteQuestionHandler, getAllQuestionsHandler, getQuestionHandler } from '../controllers/questions.js';
|
||||
import answerRoutes from './answers.js';
|
||||
import { adminOnly, studentsOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { updateAnswerHandler } from '../controllers/answers';
|
||||
import { onlyAllowAuthor, onlyAllowAuthorRequest, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks';
|
||||
import { adminOnly, studentsOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { updateAnswerHandler } from '../controllers/answers.js';
|
||||
import { onlyAllowAuthor, onlyAllowAuthorRequest, onlyAllowIfHasAccessToQuestion } from '../middleware/auth/checks/question-checks.js';
|
||||
|
||||
const router = express.Router({ mergeParams: true });
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import {
|
|||
getStudentRequestHandler,
|
||||
getStudentRequestsHandler,
|
||||
} from '../controllers/students.js';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks';
|
||||
import { onlyAllowStudentHimselfAndTeachersOfClass } from '../middleware/auth/checks/class-auth-checks';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
|
||||
import { onlyAllowStudentHimselfAndTeachersOfClass } from '../middleware/auth/checks/class-auth-checks.js';
|
||||
|
||||
// Under /:username/joinRequests/
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import {
|
|||
getStudentSubmissionsHandler,
|
||||
} from '../controllers/students.js';
|
||||
import joinRequestRouter from './student-join-requests.js';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks';
|
||||
import { adminOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
|
||||
import { adminOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ import {
|
|||
getAllInvitationsHandler,
|
||||
getInvitationHandler,
|
||||
updateInvitationHandler,
|
||||
} from '../controllers/teacher-invitations';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks';
|
||||
} from '../controllers/teacher-invitations.js';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
|
||||
import {
|
||||
onlyAllowReceiverBody,
|
||||
onlyAllowSender,
|
||||
onlyAllowSenderBody,
|
||||
onlyAllowSenderOrReceiver,
|
||||
} from '../middleware/auth/checks/teacher-invitation-checks';
|
||||
} from '../middleware/auth/checks/teacher-invitation-checks.js';
|
||||
|
||||
const router = express.Router({ mergeParams: true });
|
||||
|
||||
|
|
|
@ -11,10 +11,9 @@ import {
|
|||
updateStudentJoinRequestHandler,
|
||||
} from '../controllers/teachers.js';
|
||||
import invitationRouter from './teacher-invitations.js';
|
||||
|
||||
import { adminOnly } from '../middleware/auth/checks/auth-checks';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks';
|
||||
import { onlyAllowTeacherOfClass } from '../middleware/auth/checks/class-auth-checks';
|
||||
import { adminOnly } from '../middleware/auth/checks/auth-checks.js';
|
||||
import { onlyAllowUserHimself } from '../middleware/auth/checks/user-auth-checks.js';
|
||||
import { onlyAllowTeacherOfClass } from '../middleware/auth/checks/class-auth-checks.js';
|
||||
const router = express.Router();
|
||||
|
||||
// Root endpoint used to search objects
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import express from 'express';
|
||||
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();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment';
|
|||
import { fetchStudent } from './students.js';
|
||||
import { NotFoundException } from '../exceptions/not-found-exception.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(
|
||||
loId: LearningObjectIdentifier,
|
||||
|
|
|
@ -24,8 +24,8 @@ import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/subm
|
|||
import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
|
||||
import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request';
|
||||
import { ConflictException } from '../exceptions/conflict-exception.js';
|
||||
import { Submission } from '../entities/assignments/submission.entity';
|
||||
import { mapToUsername } from '../interfaces/user';
|
||||
import { Submission } from '../entities/assignments/submission.entity.js';
|
||||
import { mapToUsername } from '../interfaces/user.js';
|
||||
|
||||
export async function getAllStudents(full: boolean): Promise<StudentDTO[] | string[]> {
|
||||
const studentRepository = getStudentRepository();
|
||||
|
|
|
@ -30,7 +30,7 @@ import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
|
|||
import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request';
|
||||
import { ClassStatus } from '@dwengo-1/common/util/class-join-request';
|
||||
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[]> {
|
||||
const teacherRepository: TeacherRepository = getTeacherRepository();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue