Skip to content

Commit

Permalink
chore(api): ✏️ fix ResponseError typo
Browse files Browse the repository at this point in the history
  • Loading branch information
DerZade committed Oct 6, 2023
1 parent 900ff27 commit f63bb97
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/src/utils/ResponseError.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default class ReponseError extends Error {
export default class ResponseError extends Error {
public static readonly type = 'ResponseError';

public status: number;
Expand Down
8 changes: 4 additions & 4 deletions api/src/utils/sso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -35,7 +35,7 @@ async function fetchUser (token: string): Promise<SSOUser | null> {
})
});

if (!res.ok) throw new ReponseError(401);
if (!res.ok) throw new ResponseError(401);

const json = await res.json() as { data: { authenticate: SSOUser | null } };

Expand All @@ -45,7 +45,7 @@ async function fetchUser (token: string): Promise<SSOUser | null> {
async function validateToken (token: string): Promise<void> {
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;
Expand All @@ -55,7 +55,7 @@ async function validateToken (token: string): Promise<void> {
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 {
Expand Down
6 changes: 3 additions & 3 deletions api/src/v1/routes/container.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions api/src/v1/routes/page.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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');
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions api/src/v1/routes/upload.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit f63bb97

Please sign in to comment.