From 9d239a0f6549fcf110c01fd7bf4f23eb044feee7 Mon Sep 17 00:00:00 2001 From: DerZade Date: Fri, 6 Oct 2023 20:47:54 +0200 Subject: [PATCH] chore(api): :pencil2: fix ResponseError typo --- api/src/utils/ResponseError.ts | 2 +- api/src/utils/sso.ts | 8 ++++---- api/src/v1/routes/container.router.ts | 6 +++--- api/src/v1/routes/page.router.ts | 8 ++++---- api/src/v1/routes/upload.router.ts | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/api/src/utils/ResponseError.ts b/api/src/utils/ResponseError.ts index 2a03813..50a01a1 100644 --- a/api/src/utils/ResponseError.ts +++ b/api/src/utils/ResponseError.ts @@ -1,4 +1,4 @@ -export default class ReponseError extends Error { +export default class ResponseError extends Error { public static readonly type = 'ResponseError'; public status: number; diff --git a/api/src/utils/sso.ts b/api/src/utils/sso.ts index fc8fd14..fc272b7 100644 --- a/api/src/utils/sso.ts +++ b/api/src/utils/sso.ts @@ -2,7 +2,7 @@ import { type Request, type Response, type NextFunction } from 'express/index'; import fetch from 'node-fetch'; import { globalErrorHandler } from './express'; -import ReponseError from './ResponseError'; +import ResponseError from './ResponseError'; // eslint-disable-next-line @typescript-eslint/no-var-requires const config = require('../../config/config.json'); @@ -35,7 +35,7 @@ async function fetchUser (token: string): Promise { }) }); - if (!res.ok) throw new ReponseError(401); + if (!res.ok) throw new ResponseError(401); const json = await res.json() as { data: { authenticate: SSOUser | null } }; @@ -45,7 +45,7 @@ async function fetchUser (token: string): Promise { async function validateToken (token: string): Promise { const user = await fetchUser(token); - if (user === null) throw new ReponseError(401); + if (user === null) throw new ResponseError(401); const groups = user.groups.map(g => g.tag); const admin = user.admin; @@ -55,7 +55,7 @@ async function validateToken (token: string): Promise { if (groups.includes(grp)) isInGroup = true; } - if (!admin && !isInGroup) throw new ReponseError(403); + if (!admin && !isInGroup) throw new ResponseError(403); } function extractToken (req: Request): string { diff --git a/api/src/v1/routes/container.router.ts b/api/src/v1/routes/container.router.ts index 7b9dc5b..44a2a07 100644 --- a/api/src/v1/routes/container.router.ts +++ b/api/src/v1/routes/container.router.ts @@ -3,7 +3,7 @@ import { wrapAsync, globalErrorHandler, return422 } from '../../utils/express'; import { param, body, matchedData } from 'express-validator'; import { Container } from '../../models'; import { ssoCheckAuthorized } from '../../utils/sso'; -import ReponseError from '../../utils/ResponseError'; +import ResponseError from '../../utils/ResponseError'; const defaultContainerRules = [ body('heading').optional().isString(), @@ -44,7 +44,7 @@ containerRouter.put('/:id', [ const container: Container | null = await Container.findByPk(id); if (container === null) { - throw new ReponseError(404, `Container with id '${id}' not found.`); + throw new ResponseError(404, `Container with id '${id}' not found.`); } const updatedContainer = await container.update(updateData); @@ -62,7 +62,7 @@ containerRouter.delete('/:id', [ const container: Container | null = await Container.findByPk(id); if (container === null) { - throw new ReponseError(404, `Container with id '${id}' not found.`); + throw new ResponseError(404, `Container with id '${id}' not found.`); } await container.destroy(); diff --git a/api/src/v1/routes/page.router.ts b/api/src/v1/routes/page.router.ts index 0726e77..fb1ec13 100644 --- a/api/src/v1/routes/page.router.ts +++ b/api/src/v1/routes/page.router.ts @@ -3,7 +3,7 @@ import { wrapAsync, globalErrorHandler, return422 } from '../../utils/express'; import { Page } from '../../models'; import { body, matchedData } from 'express-validator'; import { ssoCheckAuthorized } from '../../utils/sso'; -import ReponseError from '../../utils/ResponseError'; +import ResponseError from '../../utils/ResponseError'; const pageRouter = Router(); @@ -13,7 +13,7 @@ pageRouter.get('/*', wrapAsync(async (req, res) => { const page = await Page.findByPk(slug); if (page === null) { - throw new ReponseError(404, `Page with slug '${slug}' not found.`); + throw new ResponseError(404, `Page with slug '${slug}' not found.`); } res.header('Cache-Control', 'no-cache'); @@ -36,7 +36,7 @@ pageRouter.put('/*', [ const page: Page | null = await Page.findByPk(slug); if (page === null) { - throw new ReponseError(404, `Page with slug '${slug}' not found.`); + throw new ResponseError(404, `Page with slug '${slug}' not found.`); } const updatedPage = await page.update(updateData); @@ -68,7 +68,7 @@ pageRouter.delete('/*', [ const page: Page | null = await Page.findByPk(slug); if (page === null) { - throw new ReponseError(404, `Container with slug '${slug}' not found.`); + throw new ResponseError(404, `Container with slug '${slug}' not found.`); } await page.destroy(); diff --git a/api/src/v1/routes/upload.router.ts b/api/src/v1/routes/upload.router.ts index 6e2bec6..c56a6f1 100644 --- a/api/src/v1/routes/upload.router.ts +++ b/api/src/v1/routes/upload.router.ts @@ -2,7 +2,7 @@ import { Router } from 'express'; import { globalErrorHandler, wrapAsync } from '../../utils/express'; import { UploadService } from '../../utils/UploadService'; import { ssoCheckAuthorized } from '../../utils/sso'; -import ReponseError from '../../utils/ResponseError'; +import ResponseError from '../../utils/ResponseError'; import * as bodyParser from 'body-parser'; const uploadService = UploadService.getInstance(); @@ -19,7 +19,7 @@ uploadRouter.post('/', [ const mime = contentTypeHeader.toLowerCase(); if (!UploadService.ALLOWED_MIME_TYPES.includes(mime)) { - throw new ReponseError(415); + throw new ResponseError(415); } const fileName = uploadService.saveFile(req.body, mime);