diff --git a/lib/middleware.js b/lib/middleware.js index 9e46b0c8..5cbe9c2c 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -18,9 +18,13 @@ export function use(middleware) { export const useCors = use(cors()); export const useSession = use(async (req, res, next) => { - const session = await verifySession(req).catch(e => { + let session; + + try { + session = await verifySession(req); + } catch (e) { return serverError(res, e.message); - }); + } if (!session) { return badRequest(res); @@ -31,9 +35,13 @@ export const useSession = use(async (req, res, next) => { }); export const useAuth = use(async (req, res, next) => { - const token = await verifyAuthToken(req).catch(e => { + let token; + + try { + token = await verifyAuthToken(req); + } catch (e) { return serverError(res, e.message); - }); + } if (!token) { return unauthorized(res);