const Security = require('../src/security.js'); module.exports = { register: app => { app.router.get("/api/access/list", (req, res) => { app.routerUtils.onApiRequest(req, res); app.routerUtils.jsonResponse(res, req.accessList); }); app.router.post("/api/access/link", async (req, res) => { // /api/access/link, post: { linkId: string } app.routerUtils.onApiRequest(req, res); if (!req.post?.linkId?.length) return app.routerUtils.httpResponse(res, 400, "Missing argument"); let access = Security.addLinkToSession(req, req.post.linkId); app.routerUtils.jsonResponse(res, access); }); app.router.del("/api/access/:id", (req, res) => { app.routerUtils.onApiRequest(req, res); Security.removeFromSession(req, req.params.id); let access = Security.getAccessList(req.cookies); app.routerUtils.jsonResponse(res, access); }); app.router.get("/api/media/list", async (req, res) => { app.routerUtils.onApiRequest(req, res); app.routerUtils.jsonResponse(res, { start: 0, end: 0, data: [] }); }); }};