chore: format
This commit is contained in:
parent
305bf8b571
commit
7a5a1a5e9d
1 changed files with 99 additions and 97 deletions
194
index.js
194
index.js
|
|
@ -10,14 +10,13 @@ const { Eta } = require("eta");
|
||||||
const { match } = require("path-to-regexp");
|
const { match } = require("path-to-regexp");
|
||||||
const bcrypt = require("bcrypt");
|
const bcrypt = require("bcrypt");
|
||||||
const cheerio = require("cheerio");
|
const cheerio = require("cheerio");
|
||||||
const webPush = require('web-push');
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const _expressWs = require("express-ws")(app);
|
const _expressWs = require("express-ws")(app);
|
||||||
const bodyParser = require("body-parser");
|
const bodyParser = require("body-parser");
|
||||||
const model = require("./db")
|
const model = require("./db");
|
||||||
const PORT = 3000;
|
const PORT = 3000;
|
||||||
|
|
||||||
const db = model.db
|
const db = model.db;
|
||||||
|
|
||||||
let viewpath = path.join(__dirname, "views");
|
let viewpath = path.join(__dirname, "views");
|
||||||
let eta = new Eta({ views: viewpath, cache: false, autoEscape: true });
|
let eta = new Eta({ views: viewpath, cache: false, autoEscape: true });
|
||||||
|
|
@ -28,16 +27,6 @@ app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
app.use(express.static("public"));
|
app.use(express.static("public"));
|
||||||
app.use(fileUpload());
|
app.use(fileUpload());
|
||||||
|
|
||||||
const publicVapidKey = 'BCW4o4mLShjgONRK21jwTT44ri49JZfrIeJ-W089TVatopdDh8UNujEptonafxM2ttbUPm4wbZF39GvY3dZWAO0';
|
|
||||||
const privateVapidKey = 'sXpmx2nRwvVWhGt7uBysZnmFStf9QjaafGd9Ereo4Gw';
|
|
||||||
|
|
||||||
// Configure web-push with your VAPID details
|
|
||||||
webPush.setVapidDetails(
|
|
||||||
'mailto:signups@sheepmail.net', // a mailto URL or URL
|
|
||||||
publicVapidKey,
|
|
||||||
privateVapidKey
|
|
||||||
);
|
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
session({
|
session({
|
||||||
store: new SQLiteStore({ client: db, expired: { clear: true } }),
|
store: new SQLiteStore({ client: db, expired: { clear: true } }),
|
||||||
|
|
@ -45,7 +34,7 @@ app.use(
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: true,
|
saveUninitialized: true,
|
||||||
cookie: { secure: false },
|
cookie: { secure: false },
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
function bootstrapContext(db, structureId, routeId, initContext) {
|
function bootstrapContext(db, structureId, routeId, initContext) {
|
||||||
|
|
@ -70,19 +59,22 @@ function bootstrapContext(db, structureId, routeId, initContext) {
|
||||||
console: {
|
console: {
|
||||||
log: function (...content) {
|
log: function (...content) {
|
||||||
const s = content.reduce((acc, curr) => {
|
const s = content.reduce((acc, curr) => {
|
||||||
console.log(curr)
|
console.log(curr);
|
||||||
return acc + (acc ? ' ' : '') + `${util.inspect(curr, {
|
return (
|
||||||
showHidden: false,
|
acc +
|
||||||
depth: null, // `null` lets you see the full depth of the object
|
(acc ? " " : "") +
|
||||||
colors: false, // Setting this to true uses ANSI color codes
|
`${util.inspect(curr, {
|
||||||
compact: false
|
showHidden: false,
|
||||||
})
|
depth: null, // `null` lets you see the full depth of the object
|
||||||
}`;
|
colors: false, // Setting this to true uses ANSI color codes
|
||||||
}, '');
|
compact: false,
|
||||||
|
})}`
|
||||||
|
);
|
||||||
|
}, "");
|
||||||
|
|
||||||
model.createLog(db, structureId, routeId, s)
|
model.createLog(db, structureId, routeId, s);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
for (let appDb of dbs) {
|
for (let appDb of dbs) {
|
||||||
let dbInstance = model.getDbInstance(appDb.id);
|
let dbInstance = model.getDbInstance(appDb.id);
|
||||||
|
|
@ -110,7 +102,7 @@ function bootstrapWebsocketHandler(route) {
|
||||||
const context = bootstrapContext(db, route.structure_id, route.id, { app });
|
const context = bootstrapContext(db, route.structure_id, route.id, { app });
|
||||||
let result = vm.runInContext(
|
let result = vm.runInContext(
|
||||||
route.handler + `\n\napp.ws("${routeWithPrefix(route)}", handler)`,
|
route.handler + `\n\napp.ws("${routeWithPrefix(route)}", handler)`,
|
||||||
context
|
context,
|
||||||
);
|
);
|
||||||
model.updateRoute(db, { ...route, error: null });
|
model.updateRoute(db, { ...route, error: null });
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -153,7 +145,6 @@ buildRoutes();
|
||||||
// | | _____| || |___ | | | |
|
// | | _____| || |___ | | | |
|
||||||
// |_______||_______||_______||___| |_|
|
// |_______||_______||_______||___| |_|
|
||||||
|
|
||||||
|
|
||||||
app.post("/register", async (req, res) => {
|
app.post("/register", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { username, password } = req.body;
|
const { username, password } = req.body;
|
||||||
|
|
@ -178,7 +169,7 @@ app.post("/login", async (req, res) => {
|
||||||
return res.send(
|
return res.send(
|
||||||
eta.render("auth/login", {
|
eta.render("auth/login", {
|
||||||
error: "are you sure you entered that right?",
|
error: "are you sure you entered that right?",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -216,7 +207,7 @@ function bootstrapTemplateWithHTMXetc(
|
||||||
blissClone,
|
blissClone,
|
||||||
blissCopy,
|
blissCopy,
|
||||||
headInjection,
|
headInjection,
|
||||||
htmxRequest = false
|
htmxRequest = false,
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
htmlString.toLowerCase().startsWith("<html>") ||
|
htmlString.toLowerCase().startsWith("<html>") ||
|
||||||
|
|
@ -282,8 +273,8 @@ app.get("/workshop", (req, res) => {
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/index", {
|
eta.render("workshop/index", {
|
||||||
structures: model.getStructures(db),
|
structures: model.getStructures(db),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -308,8 +299,8 @@ function sidebarStuff(db, structId) {
|
||||||
app.get("/workshop/:structure_id", (req, res) => {
|
app.get("/workshop/:structure_id", (req, res) => {
|
||||||
return res.send(
|
return res.send(
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/editor", sidebarStuff(db, req.params.structure_id))
|
eta.render("workshop/editor", sidebarStuff(db, req.params.structure_id)),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -324,7 +315,7 @@ app.post("/workshop/:structure_id/clone", (req, res) => {
|
||||||
1,
|
1,
|
||||||
// req.session.userId,
|
// req.session.userId,
|
||||||
routePrefix,
|
routePrefix,
|
||||||
req.body.clone_dbs
|
req.body.clone_dbs,
|
||||||
);
|
);
|
||||||
buildRoutes();
|
buildRoutes();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -349,7 +340,7 @@ app.get("/workshop/:structure_id/db/:db_id", (req, res) => {
|
||||||
const structdb = model.getDbForStructure(
|
const structdb = model.getDbForStructure(
|
||||||
db,
|
db,
|
||||||
req.params.structure_id,
|
req.params.structure_id,
|
||||||
req.params.db_id
|
req.params.db_id,
|
||||||
);
|
);
|
||||||
if (!structdb) {
|
if (!structdb) {
|
||||||
return res.send("uh oh");
|
return res.send("uh oh");
|
||||||
|
|
@ -359,8 +350,8 @@ app.get("/workshop/:structure_id/db/:db_id", (req, res) => {
|
||||||
eta.render("workshop/db_garden", {
|
eta.render("workshop/db_garden", {
|
||||||
db: structdb,
|
db: structdb,
|
||||||
...sidebarStuff(db, req.params.structure_id),
|
...sidebarStuff(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -385,14 +376,14 @@ app.post("/workshop/:structure_id/route", (req, res) => {
|
||||||
req.body.verb,
|
req.body.verb,
|
||||||
p[0] == "/" ? p.substring(1) : "/" + p,
|
p[0] == "/" ? p.substring(1) : "/" + p,
|
||||||
req.params.structure_id,
|
req.params.structure_id,
|
||||||
dummyHandler
|
dummyHandler,
|
||||||
);
|
);
|
||||||
// todo optimize by only adding new, don't just rebuild all
|
// todo optimize by only adding new, don't just rebuild all
|
||||||
buildRoutes();
|
buildRoutes();
|
||||||
return smartRedirect(
|
return smartRedirect(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
`/workshop/${req.params.structure_id}/route/${route}`
|
`/workshop/${req.params.structure_id}/route/${route}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -419,14 +410,16 @@ app.put("/workshop/:structure_id/db/:db_id/library", (req, res) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
let evaledCode = vm.runInContext(appDb.library, context);
|
let evaledCode = vm.runInContext(appDb.library, context);
|
||||||
let stdout = capturedOutput.map(v => {
|
let stdout = capturedOutput
|
||||||
return util.inspect(v, {
|
.map((v) => {
|
||||||
showHidden: false,
|
return util.inspect(v, {
|
||||||
depth: null, // `null` lets you see the full depth of the object
|
showHidden: false,
|
||||||
colors: false, // Setting this to true uses ANSI color codes
|
depth: null, // `null` lets you see the full depth of the object
|
||||||
compact: false
|
colors: false, // Setting this to true uses ANSI color codes
|
||||||
|
compact: false,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
}).join("\n");
|
.join("\n");
|
||||||
return res.send(`${stdout}\n\n> ${evaledCode}`.trim());
|
return res.send(`${stdout}\n\n> ${evaledCode}`.trim());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.send(`${e}\n\n${e.stack}`);
|
return res.send(`${e}\n\n${e.stack}`);
|
||||||
|
|
@ -443,16 +436,19 @@ app.post("/workshop/:structure_id/db/:db_id/repl", (req, res) => {
|
||||||
module: { exports: null },
|
module: { exports: null },
|
||||||
sql: dbInstance,
|
sql: dbInstance,
|
||||||
console: {
|
console: {
|
||||||
log: (...args) => capturedOutput.push(
|
log: (...args) =>
|
||||||
args.map(v => {
|
capturedOutput.push(
|
||||||
return util.inspect(v, {
|
args
|
||||||
showHidden: false,
|
.map((v) => {
|
||||||
depth: null, // `null` lets you see the full depth of the object
|
return util.inspect(v, {
|
||||||
colors: false, // Setting this to true uses ANSI color codes
|
showHidden: false,
|
||||||
compact: false
|
depth: null, // `null` lets you see the full depth of the object
|
||||||
})
|
colors: false, // Setting this to true uses ANSI color codes
|
||||||
}
|
compact: false,
|
||||||
).join(" ")),
|
});
|
||||||
|
})
|
||||||
|
.join(" "),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const libraryScript = new vm.Script(appDb.library);
|
const libraryScript = new vm.Script(appDb.library);
|
||||||
|
|
@ -475,13 +471,13 @@ app.post("/workshop/:structure_id/template", (req, res) => {
|
||||||
req.params.structure_id,
|
req.params.structure_id,
|
||||||
name,
|
name,
|
||||||
"<div>henlo <%= it.name %></div>",
|
"<div>henlo <%= it.name %></div>",
|
||||||
"it = { name: 'templates!' };"
|
"it = { name: 'templates!' };",
|
||||||
);
|
);
|
||||||
|
|
||||||
return smartRedirect(
|
return smartRedirect(
|
||||||
req,
|
req,
|
||||||
res,
|
res,
|
||||||
`/workshop/${req.params.structure_id}/template/${template}`
|
`/workshop/${req.params.structure_id}/template/${template}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -490,7 +486,11 @@ app.put("/workshop/:structure_id/template/:template_id", (req, res) => {
|
||||||
let content = req.body.content;
|
let content = req.body.content;
|
||||||
let test_object = req.body.test_object;
|
let test_object = req.body.test_object;
|
||||||
|
|
||||||
model.updateTemplate(db, { ...model.updateTemplate(db, id), content, test_object });
|
model.updateTemplate(db, {
|
||||||
|
...model.updateTemplate(db, id),
|
||||||
|
content,
|
||||||
|
test_object,
|
||||||
|
});
|
||||||
|
|
||||||
return res.send("good");
|
return res.send("good");
|
||||||
});
|
});
|
||||||
|
|
@ -499,16 +499,17 @@ app.get("/workshop/:structure_id/template/:template_id", (req, res) => {
|
||||||
const template = model.getTemplate(db, req.params.template_id);
|
const template = model.getTemplate(db, req.params.template_id);
|
||||||
|
|
||||||
console.log("wassup", {
|
console.log("wassup", {
|
||||||
template: template,
|
template: template,
|
||||||
...sidebarStuff(db, req.params.structure_id),})
|
...sidebarStuff(db, req.params.structure_id),
|
||||||
|
});
|
||||||
|
|
||||||
return res.send(
|
return res.send(
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/template", {
|
eta.render("workshop/template", {
|
||||||
template: template,
|
template: template,
|
||||||
...sidebarStuff(db, req.params.structure_id),
|
...sidebarStuff(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -516,7 +517,7 @@ app.get("/workshop/:structure_id/template/:template_id/preview", (req, res) => {
|
||||||
const template = model.getTemplate(db, req.params.template_id);
|
const template = model.getTemplate(db, req.params.template_id);
|
||||||
const struct = model.getStructure(db, req.params.structure_id);
|
const struct = model.getStructure(db, req.params.structure_id);
|
||||||
const eta = model.getTemplater(req.params.structure_id);
|
const eta = model.getTemplater(req.params.structure_id);
|
||||||
console.log(template)
|
console.log(template);
|
||||||
|
|
||||||
const context = vm.createContext({ it: null });
|
const context = vm.createContext({ it: null });
|
||||||
vm.runInContext(template.test_object, context);
|
vm.runInContext(template.test_object, context);
|
||||||
|
|
@ -532,14 +533,17 @@ app.get("/workshop/:structure_id/template/:template_id/preview", (req, res) => {
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
struct.head_injection,
|
struct.head_injection,
|
||||||
false
|
false,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/workshop/:structure_id/route/:id", (req, res) => {
|
app.get("/workshop/:structure_id/route/:id", (req, res) => {
|
||||||
const route = model.getRoute(db, req.params.id);
|
const route = model.getRoute(db, req.params.id);
|
||||||
let routePrefix = model.getStructure(db, req.params.structure_id).route_prefix;
|
let routePrefix = model.getStructure(
|
||||||
|
db,
|
||||||
|
req.params.structure_id,
|
||||||
|
).route_prefix;
|
||||||
let previewUrl = routePrefix
|
let previewUrl = routePrefix
|
||||||
? path.join(routePrefix || "", route.path)
|
? path.join(routePrefix || "", route.path)
|
||||||
: route.path;
|
: route.path;
|
||||||
|
|
@ -551,22 +555,21 @@ app.get("/workshop/:structure_id/route/:id", (req, res) => {
|
||||||
previewUrl:
|
previewUrl:
|
||||||
route["verb"] == "GET" ? previewUrl : "/workshop/do-something-here",
|
route["verb"] == "GET" ? previewUrl : "/workshop/do-something-here",
|
||||||
...sidebarStuff(db, req.params.structure_id),
|
...sidebarStuff(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/workshop/:structure_id/route/:route_id/logs", (req, res) => {
|
app.get("/workshop/:structure_id/route/:route_id/logs", (req, res) => {
|
||||||
const since = req.query.since
|
const since = req.query.since;
|
||||||
let logs = []
|
let logs = [];
|
||||||
if (since != undefined) {
|
if (since != undefined) {
|
||||||
logs = model.getNewLogsByRoute(db, req.params.route_id, since)
|
logs = model.getNewLogsByRoute(db, req.params.route_id, since);
|
||||||
}
|
} else {
|
||||||
else {
|
logs = model.getLogsByRoute(db, req.params.route_id);
|
||||||
logs = model.getLogsByRoute(db, req.params.route_id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastId = model.getMostRecentLogIdByRoute(db, req.params.route_id)
|
const lastId = model.getMostRecentLogIdByRoute(db, req.params.route_id);
|
||||||
|
|
||||||
return res.send(
|
return res.send(
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
|
|
@ -575,12 +578,11 @@ app.get("/workshop/:structure_id/route/:route_id/logs", (req, res) => {
|
||||||
structId: req.params.structure_id,
|
structId: req.params.structure_id,
|
||||||
routeId: req.params.route_id,
|
routeId: req.params.route_id,
|
||||||
since: lastId,
|
since: lastId,
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// POST route to handle file upload
|
// POST route to handle file upload
|
||||||
app.post("/workshop/:structure_id/files", (req, res) => {
|
app.post("/workshop/:structure_id/files", (req, res) => {
|
||||||
if (!req.files || Object.keys(req.files).length === 0) {
|
if (!req.files || Object.keys(req.files).length === 0) {
|
||||||
|
|
@ -608,7 +610,7 @@ app.post("/workshop/:structure_id/files", (req, res) => {
|
||||||
name,
|
name,
|
||||||
storedPath,
|
storedPath,
|
||||||
mime_type,
|
mime_type,
|
||||||
mime_subtype
|
mime_subtype,
|
||||||
);
|
);
|
||||||
|
|
||||||
let file = model.getFile(db, id);
|
let file = model.getFile(db, id);
|
||||||
|
|
@ -640,8 +642,8 @@ app.get("/workshop/:structure_id/files", (req, res) => {
|
||||||
eta.render("workshop/files", {
|
eta.render("workshop/files", {
|
||||||
files,
|
files,
|
||||||
...sidebarStuff(db, structure_id),
|
...sidebarStuff(db, structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -650,8 +652,8 @@ app.get("/workshop/:structure_id/settings", (req, res) => {
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/settings", {
|
eta.render("workshop/settings", {
|
||||||
...sidebarStuff(db, req.params.structure_id),
|
...sidebarStuff(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -682,8 +684,8 @@ app.get("/workshop/:structure_id/new_template_modal", (req, res) => {
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/new_template_modal", {
|
eta.render("workshop/new_template_modal", {
|
||||||
structure: model.getStructure(db, req.params.structure_id),
|
structure: model.getStructure(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -692,8 +694,8 @@ app.get("/workshop/:structure_id/new_route_modal", (req, res) => {
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/new_route_modal", {
|
eta.render("workshop/new_route_modal", {
|
||||||
structure: model.getStructure(db, req.params.structure_id),
|
structure: model.getStructure(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -702,8 +704,8 @@ app.get("/workshop/:structure_id/new_db_modal", (req, res) => {
|
||||||
bootstrapTemplateWithHTMXetc(
|
bootstrapTemplateWithHTMXetc(
|
||||||
eta.render("workshop/new_db_modal", {
|
eta.render("workshop/new_db_modal", {
|
||||||
structure: model.getStructure(db, req.params.structure_id),
|
structure: model.getStructure(db, req.params.structure_id),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -717,8 +719,8 @@ app.get("/workshop/:structure_id/clone_modal", (req, res) => {
|
||||||
structure,
|
structure,
|
||||||
dbs,
|
dbs,
|
||||||
defaultRoutePrefix: path.join(structure.route_prefix || "", "clone"),
|
defaultRoutePrefix: path.join(structure.route_prefix || "", "clone"),
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -771,13 +773,13 @@ app.all("*", (req, res) => {
|
||||||
`/workshop/${route.structure_id}/clone_modal/`,
|
`/workshop/${route.structure_id}/clone_modal/`,
|
||||||
verb == "GET" ? embedHTML(req.originalUrl) : null,
|
verb == "GET" ? embedHTML(req.originalUrl) : null,
|
||||||
structure.head_injection,
|
structure.head_injection,
|
||||||
req.headers["hx-request"]
|
req.headers["hx-request"],
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
return vm.runInContext(
|
return vm.runInContext(
|
||||||
(route.handler += `\n\nhandler(req, res)`),
|
(route.handler += `\n\nhandler(req, res)`),
|
||||||
context
|
context,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e.stack ? `${e}\n\n${e.stack}` : `${e}`;
|
const error = e.stack ? `${e}\n\n${e.stack}` : `${e}`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue