Initial auth library commmit

This commit is contained in:
2023-05-02 01:14:23 -04:00
parent a1d60a5042
commit 3411ae1234
17 changed files with 585 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { StatusCodes } from "http-status-codes";
import { Context, Next } from "koa";
export const errorHandler = async (ctx: Context, next: Next) => {
try {
await next();
} catch (error: any) {
ctx.status = error.statusCode || error.status || StatusCodes.INTERNAL_SERVER_ERROR;
error.status = ctx.status;
ctx.body = { error };
ctx.app.emit('error', error, ctx);
}
};