41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
var isPrepared = false;
|
|
var handle = function () {
|
|
throw nextError;
|
|
}
|
|
var sveltekitError = null;
|
|
|
|
try {
|
|
// process.cwd() is the webroot, the webroot will then act as a SvelteKit app directory
|
|
async function init() {
|
|
try {
|
|
var handlerModule = await import(process.cwd() + "/build/handler.js");
|
|
handle = handlerModule.handler;
|
|
isPrepared = true;
|
|
} catch (err) {
|
|
sveltekitError = err;
|
|
}
|
|
}
|
|
init();
|
|
} catch (err) {
|
|
sveltekitError = err;
|
|
}
|
|
|
|
function Mod() {}
|
|
Mod.prototype.callback = function callback(req, res, serverconsole, responseEnd, href, ext, uobject, search, defaultpage, users, page404, head, foot, fd, elseCallback, configJSON, callServerError, getCustomHeaders, origHref, redirect, parsePostData) {
|
|
return function () {
|
|
try {
|
|
if (sveltekitError) throw sveltekitError;
|
|
if (!isPrepared) {
|
|
callServerError(503, "sveltekit-integration/1.0.0");
|
|
serverconsole.errmessage("SvelteKit application not yet fully loaded.");
|
|
return;
|
|
}
|
|
handle(req, res);
|
|
serverconsole.resmessage("SvelteKit request successfully processed.");
|
|
} catch (err) {
|
|
callServerError(500, "sveltekit-integration/1.0.0", err);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Mod;
|