UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

37 lines (36 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.activateRoutes = void 0; const globals_1 = require("../../shared/globals"); const utils_1 = require("../../utils"); const open_file_with_vscode_1 = require("./open-file-with-vscode"); const activateRoutes = (server) => { const routes = globals_1.GlobalConfig.server.routes; if (Array.isArray(routes)) { for (const route of routes) { server.use(route.toExpressRoutes()); } } else { server.use(routes.toExpressRoutes()); } server.use("/open-file-in-editor", open_file_with_vscode_1.openFileWithVscode); server.use((err, req, res, next) => { let csrfToken = ""; try { csrfToken = req.csrfToken(); } catch (e) { // } const data = { error: err.stack, title: err.message, csrfToken: csrfToken, host: `${req.protocol}://${req.get("host")}`, }; utils_1.Logger.error(err.stack); // Log the error stack to the console res.status(500).json(data); // Render the 500 error page }); }; exports.activateRoutes = activateRoutes;