chore: init
This commit is contained in:
commit
e569f1d2dc
2 changed files with 45 additions and 0 deletions
41
index.js
Normal file
41
index.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
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;
|
4
mod.info
Executable file
4
mod.info
Executable file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "SvelteKit integration for SVR.JS",
|
||||
"version": "Nightly-GitMain"
|
||||
}
|
Loading…
Reference in a new issue