appstage 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -6
- package/src/controllers/files.ts +0 -250
- package/src/controllers/redirect.ts +0 -29
- package/src/controllers/unhandledError.ts +0 -15
- package/src/controllers/unhandledRoute.ts +0 -14
- package/src/lib/lang/getEffectiveLocale.ts +0 -52
- package/src/lib/lang/getLocales.ts +0 -10
- package/src/lib/lang/toLanguage.ts +0 -3
- package/src/lib/logger/LogOptions.ts +0 -8
- package/src/lib/logger/ansiEscapeCodes.ts +0 -6
- package/src/lib/logger/levelColors.ts +0 -4
- package/src/lib/logger/log.ts +0 -82
- package/src/middleware/init.ts +0 -22
- package/src/middleware/lang.ts +0 -83
- package/src/middleware/requestEvents.ts +0 -29
- package/src/scripts/bin.ts +0 -40
- package/src/scripts/build.ts +0 -80
- package/src/scripts/cli.ts +0 -43
- package/src/scripts/const/commonBuildOptions.ts +0 -13
- package/src/scripts/const/entryExtensions.ts +0 -1
- package/src/scripts/types/BuildParams.ts +0 -22
- package/src/scripts/utils/buildClient.ts +0 -42
- package/src/scripts/utils/buildServer.ts +0 -36
- package/src/scripts/utils/buildServerCSS.ts +0 -40
- package/src/scripts/utils/createPostbuildPlugins.ts +0 -66
- package/src/scripts/utils/getEntries.ts +0 -22
- package/src/scripts/utils/getEntryPoints.ts +0 -25
- package/src/scripts/utils/getFirstAvailable.ts +0 -22
- package/src/scripts/utils/setEntriesExport.ts +0 -30
- package/src/scripts/utils/toImportPath.ts +0 -12
- package/src/types/Controller.ts +0 -4
- package/src/types/ErrorController.ts +0 -3
- package/src/types/LogEventPayload.ts +0 -12
- package/src/types/LogLevel.ts +0 -1
- package/src/types/Middleware.ts +0 -7
- package/src/types/MiddlewareSet.ts +0 -3
- package/src/types/RenderStatus.ts +0 -9
- package/src/types/ReqCtx.ts +0 -11
- package/src/types/TransformContent.ts +0 -11
- package/src/types/express.d.ts +0 -15
- package/src/types/global.d.ts +0 -19
- package/src/utils/createApp.ts +0 -45
- package/src/utils/cspNonce.ts +0 -6
- package/src/utils/emitLog.ts +0 -18
- package/src/utils/getEntries.ts +0 -22
- package/src/utils/getServerURL.ts +0 -38
- package/src/utils/getStatusMessage.ts +0 -5
- package/src/utils/injectNonce.ts +0 -7
- package/src/utils/renderStatus.ts +0 -20
- package/src/utils/serializeState.ts +0 -3
- package/src/utils/servePipeableStream.ts +0 -32
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const defaultPorts: Record<string, number> = {
|
|
2
|
-
"http:": 80,
|
|
3
|
-
"https:": 443,
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
export function getServerURL() {
|
|
7
|
-
let {
|
|
8
|
-
SERVER_URL: href,
|
|
9
|
-
SERVER_HOSTNAME: hostname = "localhost",
|
|
10
|
-
SERVER_PORT: port = "3000",
|
|
11
|
-
} = process.env;
|
|
12
|
-
|
|
13
|
-
let protocol = "http:";
|
|
14
|
-
|
|
15
|
-
if (href) {
|
|
16
|
-
if (href.startsWith("//")) href = `${protocol}${href}`;
|
|
17
|
-
else if (!href.includes("://")) href = `${protocol}//${href}`;
|
|
18
|
-
else protocol = href.slice(0, href.indexOf("://") + 1);
|
|
19
|
-
|
|
20
|
-
let matches = href.match(/^\w+:\/\/([^/:]+)(:(\d+))?(\/|$)/);
|
|
21
|
-
|
|
22
|
-
if (matches?.[1]) hostname = matches[1];
|
|
23
|
-
if (matches?.[3]) port = matches[3];
|
|
24
|
-
} else href = `${protocol}//${hostname}:${port}`;
|
|
25
|
-
|
|
26
|
-
let parsedPort = Number(port);
|
|
27
|
-
let origin = `${protocol}//${hostname}`;
|
|
28
|
-
|
|
29
|
-
if (parsedPort !== defaultPorts[protocol]) origin += `:${port}`;
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
href,
|
|
33
|
-
origin,
|
|
34
|
-
protocol,
|
|
35
|
-
hostname,
|
|
36
|
-
port: parsedPort,
|
|
37
|
-
};
|
|
38
|
-
}
|
package/src/utils/injectNonce.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { STATUS_CODES } from "node:http";
|
|
2
|
-
import type { RenderStatus } from "../types/RenderStatus.ts";
|
|
3
|
-
|
|
4
|
-
export const renderStatus: RenderStatus = async (req, res) => {
|
|
5
|
-
let { id, nonce } = req.ctx;
|
|
6
|
-
let statusText = `${res.statusCode} ${STATUS_CODES[res.statusCode]}`;
|
|
7
|
-
let date = `${new Date().toISOString().replace(/T/, " ").replace(/Z$/, "")} UTC`;
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
"<!DOCTYPE html>" +
|
|
11
|
-
'<html><head><meta charset="utf-8"/>' +
|
|
12
|
-
'<meta name="viewport" content="width=device-width"/>' +
|
|
13
|
-
`<title>${statusText}</title>` +
|
|
14
|
-
`<style${nonce ? ` nonce="${nonce}"` : ""}>` +
|
|
15
|
-
"body{text-align:center;}</style></head>" +
|
|
16
|
-
`<body><h1>${statusText}</h1><hr/><p>` +
|
|
17
|
-
(id ? `<code>ID: ${id}</code><br/>` : "") +
|
|
18
|
-
`<code>${date}</code></p></body></html>`
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Request, Response } from "express";
|
|
2
|
-
import { emitLog } from "./emitLog.ts";
|
|
3
|
-
import { getStatusMessage } from "./getStatusMessage.ts";
|
|
4
|
-
|
|
5
|
-
type PipeableStream = {
|
|
6
|
-
pipe: <Writable extends NodeJS.WritableStream>(
|
|
7
|
-
destination: Writable,
|
|
8
|
-
) => Writable;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export function servePipeableStream(req: Request, res: Response) {
|
|
12
|
-
return async ({ pipe }: PipeableStream, error?: unknown) => {
|
|
13
|
-
let statusCode = error ? 500 : 200;
|
|
14
|
-
|
|
15
|
-
emitLog(req.app, getStatusMessage("Stream", statusCode), {
|
|
16
|
-
level: error ? "error" : undefined,
|
|
17
|
-
req,
|
|
18
|
-
res,
|
|
19
|
-
data: error,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
res.status(statusCode);
|
|
23
|
-
|
|
24
|
-
if (statusCode >= 400) {
|
|
25
|
-
res.send(await req.app.renderStatus?.(req, res));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
res.set("Content-Type", "text/html");
|
|
30
|
-
pipe(res);
|
|
31
|
-
};
|
|
32
|
-
}
|