2022-02-26 02:20:38 +08:00
|
|
|
import ConfigurationClient from "../init/configuration";
|
2022-02-23 23:03:38 +08:00
|
|
|
import { Response, NextFunction } from "express";
|
2022-02-01 05:47:58 +08:00
|
|
|
|
2022-02-23 23:03:38 +08:00
|
|
|
async function contextMiddleware(
|
|
|
|
req: MonkeyTypes.Request,
|
|
|
|
_res: Response,
|
|
|
|
next: NextFunction
|
|
|
|
): Promise<void> {
|
2022-02-26 02:20:38 +08:00
|
|
|
const configuration = await ConfigurationClient.getCachedConfiguration(true);
|
2022-02-01 05:47:58 +08:00
|
|
|
|
2022-02-05 04:18:22 +08:00
|
|
|
req.ctx = {
|
2022-02-01 05:47:58 +08:00
|
|
|
configuration,
|
2022-02-05 04:18:22 +08:00
|
|
|
decodedToken: {
|
|
|
|
uid: null,
|
2022-02-23 23:03:38 +08:00
|
|
|
email: null,
|
2022-02-05 04:18:22 +08:00
|
|
|
},
|
2022-02-01 05:47:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
2022-02-23 03:55:48 +08:00
|
|
|
export default contextMiddleware;
|