UNPKG

907 BJavaScriptView Raw
1module.exports = ({
2 ClientConfig,
3 router,
4 cacheMiddleware,
5 asyncMiddleware,
6 getConfig,
7 handleResponse,
8 handleError,
9}) => {
10
11 /**
12 * @swagger
13 * /metadata:
14 * get:
15 * tags:
16 * - metadata
17 * summary: Get metadata
18 * produces:
19 * - application/json
20 * parameters: []
21 * responses:
22 * 200:
23 * description: Metadata
24 * schema:
25 * type: object
26 * properties:
27 * description:
28 * type: string
29 */
30 router.get(
31 '/metadata.:ext?',
32 cacheMiddleware,
33 asyncMiddleware(async (req, res) => {
34 const cc = ClientConfig(await getConfig(req.session.slug));
35
36 const clientConfig = await cc.get();
37
38 try {
39 handleResponse(req, res, clientConfig.client.metadata, true);
40 } catch (error) {
41 handleError(req, res, error);
42 }
43 })
44 );
45
46};