From b5f9cf201d09c32ff10017eb7956cf41d6167540 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 30 Dec 2020 14:01:37 +0100 Subject: [PATCH] Moved the authchecker to the middleware folder (b/c it pretty much is a glolified middleware) ref #56 --- src/app.ts | 2 +- src/{ => middlewares}/authchecker.ts | 8 ++++---- src/openapi_export.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/{ => middlewares}/authchecker.ts (93%) diff --git a/src/app.ts b/src/app.ts index 9adc9b3..44060da 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,9 +1,9 @@ import consola from "consola"; import "reflect-metadata"; import { createExpressServer } from "routing-controllers"; -import authchecker from "./authchecker"; import { config, e as errors } from './config'; import loaders from "./loaders/index"; +import authchecker from "./middlewares/authchecker"; import { ErrorHandler } from './middlewares/ErrorHandler'; const CONTROLLERS_FILE_EXTENSION = process.env.NODE_ENV === 'production' ? 'js' : 'ts'; diff --git a/src/authchecker.ts b/src/middlewares/authchecker.ts similarity index 93% rename from src/authchecker.ts rename to src/middlewares/authchecker.ts index 54ef4d7..61ca231 100644 --- a/src/authchecker.ts +++ b/src/middlewares/authchecker.ts @@ -2,10 +2,10 @@ import cookie from "cookie"; import * as jwt from "jsonwebtoken"; import { Action } from "routing-controllers"; import { getConnectionManager } from 'typeorm'; -import { config } from './config'; -import { IllegalJWTError, NoPermissionError, UserDisabledError, UserNonexistantOrRefreshtokenInvalidError } from './errors/AuthError'; -import { JwtCreator, JwtUser } from './jwtcreator'; -import { User } from './models/entities/User'; +import { config } from '../config'; +import { IllegalJWTError, NoPermissionError, UserDisabledError, UserNonexistantOrRefreshtokenInvalidError } from '../errors/AuthError'; +import { JwtCreator, JwtUser } from '../jwtcreator'; +import { User } from '../models/entities/User'; /** * Handels authorisation verification via jwt's for all api endpoints using the @Authorized decorator. diff --git a/src/openapi_export.ts b/src/openapi_export.ts index e6f2a3c..49647b5 100644 --- a/src/openapi_export.ts +++ b/src/openapi_export.ts @@ -4,8 +4,8 @@ import fs from "fs"; import "reflect-metadata"; import { createExpressServer, getMetadataArgsStorage } from "routing-controllers"; import { routingControllersToSpec } from 'routing-controllers-openapi'; -import authchecker from "./authchecker"; import { config } from './config'; +import authchecker from "./middlewares/authchecker"; import { ErrorHandler } from './middlewares/ErrorHandler'; const CONTROLLERS_FILE_EXTENSION = process.env.NODE_ENV === 'production' ? 'js' : 'ts';