✅ Complete Astro migration - PDPA compliant website
- Migrated all pages from Next.js to Astro - Added PDPA-compliant Privacy Policy (Thai) - Added PDPA-compliant Terms & Conditions (Thai) - Added Cookie Policy with disclosure (Thai) - Implemented cookie consent banner (client-side) - Integrated Umami Analytics placeholder - Blog system with 3 posts - Optimized Docker configuration for production - Static site build (184KB, 11 pages) - Ready for Easypanel deployment Backup: /Users/kunthawatgreethong/Gitea/dealplustech-backup-nextjs-20260309.tar.gz
This commit is contained in:
59
dealplustech-astro/node_modules/@astrojs/node/LICENSE
generated
vendored
Normal file
59
dealplustech-astro/node_modules/@astrojs/node/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Fred K. Schott
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
|
||||
|
||||
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
"""
|
||||
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
38
dealplustech-astro/node_modules/@astrojs/node/README.md
generated
vendored
Normal file
38
dealplustech-astro/node_modules/@astrojs/node/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# @astrojs/node
|
||||
|
||||
This adapter allows Astro to deploy your SSR site to Node targets.
|
||||
|
||||
## Documentation
|
||||
|
||||
Read the [`@astrojs/node` docs][docs]
|
||||
|
||||
## Support
|
||||
|
||||
- Get help in the [Astro Discord][discord]. Post questions in our `#support` forum, or visit our dedicated `#dev` channel to discuss current development and more!
|
||||
|
||||
- Check our [Astro Integration Documentation][astro-integration] for more on integrations.
|
||||
|
||||
- Submit bug reports and feature requests as [GitHub issues][issues].
|
||||
|
||||
## Contributing
|
||||
|
||||
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! These links will help you get started:
|
||||
|
||||
- [Contributor Manual][contributing]
|
||||
- [Code of Conduct][coc]
|
||||
- [Community Guide][community]
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
Copyright (c) 2023–present [Astro][astro]
|
||||
|
||||
[astro]: https://astro.build/
|
||||
[docs]: https://docs.astro.build/en/guides/integrations-guide/node/
|
||||
[contributing]: https://github.com/withastro/astro/blob/main/CONTRIBUTING.md
|
||||
[coc]: https://github.com/withastro/.github/blob/main/CODE_OF_CONDUCT.md
|
||||
[community]: https://github.com/withastro/.github/blob/main/COMMUNITY_GUIDE.md
|
||||
[discord]: https://astro.build/chat/
|
||||
[issues]: https://github.com/withastro/astro/issues
|
||||
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
|
||||
4
dealplustech-astro/node_modules/@astrojs/node/dist/index.d.ts
generated
vendored
Normal file
4
dealplustech-astro/node_modules/@astrojs/node/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { AstroAdapter, AstroIntegration } from 'astro';
|
||||
import type { Options, UserOptions } from './types.js';
|
||||
export declare function getAdapter(options: Options): AstroAdapter;
|
||||
export default function createIntegration(userOptions: UserOptions): AstroIntegration;
|
||||
123
dealplustech-astro/node_modules/@astrojs/node/dist/index.js
generated
vendored
Normal file
123
dealplustech-astro/node_modules/@astrojs/node/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { writeJson } from "@astrojs/internal-helpers/fs";
|
||||
import { AstroError } from "astro/errors";
|
||||
import { STATIC_HEADERS_FILE } from "./shared.js";
|
||||
function getAdapter(options) {
|
||||
return {
|
||||
name: "@astrojs/node",
|
||||
serverEntrypoint: "@astrojs/node/server.js",
|
||||
previewEntrypoint: "@astrojs/node/preview.js",
|
||||
exports: ["handler", "startServer", "options"],
|
||||
args: options,
|
||||
adapterFeatures: {
|
||||
buildOutput: "server",
|
||||
edgeMiddleware: false,
|
||||
experimentalStaticHeaders: options.experimentalStaticHeaders
|
||||
},
|
||||
supportedAstroFeatures: {
|
||||
hybridOutput: "stable",
|
||||
staticOutput: "stable",
|
||||
serverOutput: "stable",
|
||||
sharpImageService: "stable",
|
||||
i18nDomains: "experimental",
|
||||
envGetSecret: "stable"
|
||||
}
|
||||
};
|
||||
}
|
||||
const protocols = ["http:", "https:"];
|
||||
function createIntegration(userOptions) {
|
||||
if (!userOptions?.mode) {
|
||||
throw new AstroError(`Setting the 'mode' option is required.`);
|
||||
}
|
||||
const { experimentalErrorPageHost } = userOptions;
|
||||
if (experimentalErrorPageHost && (!URL.canParse(experimentalErrorPageHost) || !protocols.includes(new URL(experimentalErrorPageHost).protocol))) {
|
||||
throw new AstroError(
|
||||
`Invalid experimentalErrorPageHost: ${experimentalErrorPageHost}. It should be a valid URL.`
|
||||
);
|
||||
}
|
||||
let _options;
|
||||
let _config = void 0;
|
||||
let _routeToHeaders = void 0;
|
||||
return {
|
||||
name: "@astrojs/node",
|
||||
hooks: {
|
||||
"astro:config:setup": async ({ updateConfig, config, logger, command }) => {
|
||||
let session = config.session;
|
||||
_config = config;
|
||||
if (!session?.driver) {
|
||||
logger.info("Enabling sessions with filesystem storage");
|
||||
session = {
|
||||
...session,
|
||||
driver: "fs-lite",
|
||||
options: {
|
||||
base: fileURLToPath(new URL("sessions", config.cacheDir))
|
||||
}
|
||||
};
|
||||
}
|
||||
updateConfig({
|
||||
build: {
|
||||
redirects: false
|
||||
},
|
||||
image: {
|
||||
endpoint: {
|
||||
route: config.image.endpoint.route ?? "_image",
|
||||
entrypoint: config.image.endpoint.entrypoint ?? (command === "dev" ? "astro/assets/endpoint/dev" : "astro/assets/endpoint/node")
|
||||
}
|
||||
},
|
||||
session,
|
||||
vite: {
|
||||
ssr: {
|
||||
noExternal: ["@astrojs/node"]
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
"astro:build:generated": ({ experimentalRouteToHeaders }) => {
|
||||
_routeToHeaders = experimentalRouteToHeaders;
|
||||
},
|
||||
"astro:config:done": ({ setAdapter, config }) => {
|
||||
_options = {
|
||||
...userOptions,
|
||||
client: config.build.client?.toString(),
|
||||
server: config.build.server?.toString(),
|
||||
host: config.server.host,
|
||||
port: config.server.port,
|
||||
assets: config.build.assets,
|
||||
experimentalStaticHeaders: userOptions.experimentalStaticHeaders ?? false,
|
||||
experimentalErrorPageHost
|
||||
};
|
||||
setAdapter(getAdapter(_options));
|
||||
},
|
||||
"astro:build:done": async () => {
|
||||
if (!_config) {
|
||||
return;
|
||||
}
|
||||
if (_routeToHeaders && _routeToHeaders.size > 0) {
|
||||
const headersFileUrl = new URL(STATIC_HEADERS_FILE, _config.outDir);
|
||||
const headersValue = [];
|
||||
for (const [pathname, { headers }] of _routeToHeaders.entries()) {
|
||||
if (_config.experimental.csp) {
|
||||
const csp = headers.get("Content-Security-Policy");
|
||||
if (csp) {
|
||||
headersValue.push({
|
||||
pathname,
|
||||
headers: [
|
||||
{
|
||||
key: "Content-Security-Policy",
|
||||
value: csp
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
await writeJson(headersFileUrl, headersValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
createIntegration as default,
|
||||
getAdapter
|
||||
};
|
||||
4
dealplustech-astro/node_modules/@astrojs/node/dist/log-listening-on.d.ts
generated
vendored
Normal file
4
dealplustech-astro/node_modules/@astrojs/node/dist/log-listening-on.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type http from 'node:http';
|
||||
import https from 'node:https';
|
||||
import type { AstroIntegrationLogger } from 'astro';
|
||||
export declare function logListeningOn(logger: AstroIntegrationLogger, server: http.Server | https.Server, configuredHost: string | boolean | undefined): Promise<void>;
|
||||
57
dealplustech-astro/node_modules/@astrojs/node/dist/log-listening-on.js
generated
vendored
Normal file
57
dealplustech-astro/node_modules/@astrojs/node/dist/log-listening-on.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import https from "node:https";
|
||||
import os from "node:os";
|
||||
const wildcardHosts = /* @__PURE__ */ new Set(["0.0.0.0", "::", "0000:0000:0000:0000:0000:0000:0000:0000"]);
|
||||
async function logListeningOn(logger, server, configuredHost) {
|
||||
await new Promise((resolve) => server.once("listening", resolve));
|
||||
const protocol = server instanceof https.Server ? "https" : "http";
|
||||
const host = getResolvedHostForHttpServer(configuredHost);
|
||||
const { port } = server.address();
|
||||
const address = getNetworkAddress(protocol, host, port);
|
||||
if (host === void 0 || wildcardHosts.has(host)) {
|
||||
logger.info(
|
||||
`Server listening on
|
||||
local: ${address.local[0]}
|
||||
network: ${address.network[0]}
|
||||
`
|
||||
);
|
||||
} else {
|
||||
logger.info(`Server listening on ${address.local[0]}`);
|
||||
}
|
||||
}
|
||||
function getResolvedHostForHttpServer(host) {
|
||||
if (host === false) {
|
||||
return "localhost";
|
||||
} else if (host === true) {
|
||||
return void 0;
|
||||
} else {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
function getNetworkAddress(protocol = "http", hostname, port, base) {
|
||||
const NetworkAddress = {
|
||||
local: [],
|
||||
network: []
|
||||
};
|
||||
Object.values(os.networkInterfaces()).flatMap((nInterface) => nInterface ?? []).filter(
|
||||
(detail) => detail && detail.address && (detail.family === "IPv4" || // @ts-expect-error Node 18.0 - 18.3 returns number
|
||||
detail.family === 4)
|
||||
).forEach((detail) => {
|
||||
let host = detail.address.replace(
|
||||
"127.0.0.1",
|
||||
hostname === void 0 || wildcardHosts.has(hostname) ? "localhost" : hostname
|
||||
);
|
||||
if (host.includes(":")) {
|
||||
host = `[${host}]`;
|
||||
}
|
||||
const url = `${protocol}://${host}:${port}${base ? base : ""}`;
|
||||
if (detail.address.includes("127.0.0.1")) {
|
||||
NetworkAddress.local.push(url);
|
||||
} else {
|
||||
NetworkAddress.network.push(url);
|
||||
}
|
||||
});
|
||||
return NetworkAddress;
|
||||
}
|
||||
export {
|
||||
logListeningOn
|
||||
};
|
||||
11
dealplustech-astro/node_modules/@astrojs/node/dist/middleware.d.ts
generated
vendored
Normal file
11
dealplustech-astro/node_modules/@astrojs/node/dist/middleware.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { NodeApp } from 'astro/app/node';
|
||||
import type { Options, RequestHandler } from './types.js';
|
||||
/**
|
||||
* Creates a middleware that can be used with Express, Connect, etc.
|
||||
*
|
||||
* Similar to `createAppHandler` but can additionally be placed in the express
|
||||
* chain as an error middleware.
|
||||
*
|
||||
* https://expressjs.com/en/guide/using-middleware.html#middleware.error-handling
|
||||
*/
|
||||
export default function createMiddleware(app: NodeApp, options: Options): RequestHandler;
|
||||
29
dealplustech-astro/node_modules/@astrojs/node/dist/middleware.js
generated
vendored
Normal file
29
dealplustech-astro/node_modules/@astrojs/node/dist/middleware.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createAppHandler } from "./serve-app.js";
|
||||
function createMiddleware(app, options) {
|
||||
const handler = createAppHandler(app, options);
|
||||
const logger = app.getAdapterLogger();
|
||||
return async (...args) => {
|
||||
const [req, res, next, locals] = args;
|
||||
if (req instanceof Error) {
|
||||
const error = req;
|
||||
if (next) {
|
||||
return next(error);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
try {
|
||||
await handler(req, res, next, locals);
|
||||
} catch (err) {
|
||||
logger.error(`Could not render ${req.url}`);
|
||||
console.error(err);
|
||||
if (!res.headersSent) {
|
||||
res.writeHead(500, `Server error`);
|
||||
res.end();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
createMiddleware as default
|
||||
};
|
||||
1
dealplustech-astro/node_modules/@astrojs/node/dist/polyfill.d.ts
generated
vendored
Normal file
1
dealplustech-astro/node_modules/@astrojs/node/dist/polyfill.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
dealplustech-astro/node_modules/@astrojs/node/dist/polyfill.js
generated
vendored
Normal file
2
dealplustech-astro/node_modules/@astrojs/node/dist/polyfill.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { applyPolyfills } from "astro/app/node";
|
||||
applyPolyfills();
|
||||
3
dealplustech-astro/node_modules/@astrojs/node/dist/preview.d.ts
generated
vendored
Normal file
3
dealplustech-astro/node_modules/@astrojs/node/dist/preview.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { CreatePreviewServer } from 'astro';
|
||||
declare const createPreviewServer: CreatePreviewServer;
|
||||
export { createPreviewServer as default };
|
||||
50
dealplustech-astro/node_modules/@astrojs/node/dist/preview.js
generated
vendored
Normal file
50
dealplustech-astro/node_modules/@astrojs/node/dist/preview.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { AstroError } from "astro/errors";
|
||||
import { logListeningOn } from "./log-listening-on.js";
|
||||
import { createServer } from "./standalone.js";
|
||||
const createPreviewServer = async (preview) => {
|
||||
let ssrHandler;
|
||||
try {
|
||||
process.env.ASTRO_NODE_AUTOSTART = "disabled";
|
||||
const ssrModule = await import(preview.serverEntrypoint.toString());
|
||||
if (typeof ssrModule.handler === "function") {
|
||||
ssrHandler = ssrModule.handler;
|
||||
} else {
|
||||
throw new AstroError(
|
||||
`The server entrypoint doesn't have a handler. Are you sure this is the right file?`
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err.code === "ERR_MODULE_NOT_FOUND" && err.url === preview.serverEntrypoint.href) {
|
||||
throw new AstroError(
|
||||
`The server entrypoint ${fileURLToPath(
|
||||
preview.serverEntrypoint
|
||||
)} does not exist. Have you ran a build yet?`
|
||||
);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
const host = process.env.HOST ?? preview.host ?? "0.0.0.0";
|
||||
const port = preview.port ?? 4321;
|
||||
const server = createServer(ssrHandler, host, port);
|
||||
if (preview.headers) {
|
||||
server.server.addListener("request", (_, res) => {
|
||||
if (res.statusCode === 200) {
|
||||
for (const [name, value] of Object.entries(preview.headers ?? {})) {
|
||||
if (value) res.setHeader(name, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
logListeningOn(preview.logger, server.server, host);
|
||||
await new Promise((resolve, reject) => {
|
||||
server.server.once("listening", resolve);
|
||||
server.server.once("error", reject);
|
||||
server.server.listen(port, host);
|
||||
});
|
||||
return server;
|
||||
};
|
||||
export {
|
||||
createPreviewServer as default
|
||||
};
|
||||
8
dealplustech-astro/node_modules/@astrojs/node/dist/serve-app.d.ts
generated
vendored
Normal file
8
dealplustech-astro/node_modules/@astrojs/node/dist/serve-app.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NodeApp } from 'astro/app/node';
|
||||
import type { Options, RequestHandler } from './types.js';
|
||||
/**
|
||||
* Creates a Node.js http listener for on-demand rendered pages, compatible with http.createServer and Connect middleware.
|
||||
* If the next callback is provided, it will be called if the request does not have a matching route.
|
||||
* Intended to be used in both standalone and middleware mode.
|
||||
*/
|
||||
export declare function createAppHandler(app: NodeApp, options: Options): RequestHandler;
|
||||
88
dealplustech-astro/node_modules/@astrojs/node/dist/serve-app.js
generated
vendored
Normal file
88
dealplustech-astro/node_modules/@astrojs/node/dist/serve-app.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import { AsyncLocalStorage } from "node:async_hooks";
|
||||
import { createReadStream } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { Readable } from "node:stream";
|
||||
import { NodeApp } from "astro/app/node";
|
||||
import { resolveClientDir } from "./shared.js";
|
||||
async function readErrorPageFromDisk(client, status) {
|
||||
const filePaths = [`${status}.html`, `${status}/index.html`];
|
||||
for (const filePath of filePaths) {
|
||||
const fullPath = path.join(client, filePath);
|
||||
try {
|
||||
const stream = createReadStream(fullPath);
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.once("open", () => resolve());
|
||||
stream.once("error", reject);
|
||||
});
|
||||
const webStream = Readable.toWeb(stream);
|
||||
return new Response(webStream, {
|
||||
headers: { "Content-Type": "text/html; charset=utf-8" }
|
||||
});
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
function createAppHandler(app, options) {
|
||||
const als = new AsyncLocalStorage();
|
||||
const logger = app.getAdapterLogger();
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
const requestUrl = als.getStore();
|
||||
logger.error(`Unhandled rejection while rendering ${requestUrl}`);
|
||||
console.error(reason);
|
||||
});
|
||||
const client = resolveClientDir(options);
|
||||
const prerenderedErrorPageFetch = async (url) => {
|
||||
if (url.includes("/404")) {
|
||||
const response = await readErrorPageFromDisk(client, 404);
|
||||
if (response) return response;
|
||||
}
|
||||
if (url.includes("/500")) {
|
||||
const response = await readErrorPageFromDisk(client, 500);
|
||||
if (response) return response;
|
||||
}
|
||||
if (options.experimentalErrorPageHost) {
|
||||
const originUrl = new URL(options.experimentalErrorPageHost);
|
||||
const errorPageUrl = new URL(url);
|
||||
errorPageUrl.protocol = originUrl.protocol;
|
||||
errorPageUrl.host = originUrl.host;
|
||||
return fetch(errorPageUrl);
|
||||
}
|
||||
return new Response(null, { status: 404 });
|
||||
};
|
||||
return async (req, res, next, locals) => {
|
||||
let request;
|
||||
try {
|
||||
request = NodeApp.createRequest(req, {
|
||||
allowedDomains: app.getAllowedDomains?.() ?? []
|
||||
});
|
||||
} catch (err) {
|
||||
logger.error(`Could not render ${req.url}`);
|
||||
console.error(err);
|
||||
res.statusCode = 500;
|
||||
res.end("Internal Server Error");
|
||||
return;
|
||||
}
|
||||
const routeData = app.match(request, true);
|
||||
if (routeData) {
|
||||
const response = await als.run(
|
||||
request.url,
|
||||
() => app.render(request, {
|
||||
addCookieHeader: true,
|
||||
locals,
|
||||
routeData,
|
||||
prerenderedErrorPageFetch
|
||||
})
|
||||
);
|
||||
await NodeApp.writeResponse(response, res);
|
||||
} else if (next) {
|
||||
return next();
|
||||
} else {
|
||||
const response = await app.render(req, { addCookieHeader: true, prerenderedErrorPageFetch });
|
||||
await NodeApp.writeResponse(response, res);
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
createAppHandler
|
||||
};
|
||||
10
dealplustech-astro/node_modules/@astrojs/node/dist/serve-static.d.ts
generated
vendored
Normal file
10
dealplustech-astro/node_modules/@astrojs/node/dist/serve-static.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
import type { NodeApp } from 'astro/app/node';
|
||||
import type { Options } from './types.js';
|
||||
/**
|
||||
* Creates a Node.js http listener for static files and prerendered pages.
|
||||
* In standalone mode, the static handler is queried first for the static files.
|
||||
* If one matching the request path is not found, it relegates to the SSR handler.
|
||||
* Intended to be used only in the standalone mode.
|
||||
*/
|
||||
export declare function createStaticHandler(app: NodeApp, options: Options): (req: IncomingMessage, res: ServerResponse, ssr: () => unknown) => ServerResponse<IncomingMessage> | undefined;
|
||||
98
dealplustech-astro/node_modules/@astrojs/node/dist/serve-static.js
generated
vendored
Normal file
98
dealplustech-astro/node_modules/@astrojs/node/dist/serve-static.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { hasFileExtension, isInternalPath } from "@astrojs/internal-helpers/path";
|
||||
import send from "send";
|
||||
import { resolveClientDir } from "./shared.js";
|
||||
function createStaticHandler(app, options) {
|
||||
const client = resolveClientDir(options);
|
||||
return (req, res, ssr) => {
|
||||
if (req.url) {
|
||||
let fullUrl = req.url;
|
||||
if (req.url.includes("#")) {
|
||||
fullUrl = fullUrl.slice(0, req.url.indexOf("#"));
|
||||
}
|
||||
const [urlPath, urlQuery] = fullUrl.split("?");
|
||||
const filePath = path.join(client, app.removeBase(urlPath));
|
||||
let isDirectory = false;
|
||||
try {
|
||||
isDirectory = fs.lstatSync(filePath).isDirectory();
|
||||
} catch {
|
||||
}
|
||||
const { trailingSlash = "ignore" } = options;
|
||||
const hasSlash = urlPath.endsWith("/");
|
||||
let pathname = urlPath;
|
||||
if (app.headersMap && app.headersMap.length > 0) {
|
||||
const routeData = app.match(req, true);
|
||||
if (routeData && routeData.prerender) {
|
||||
const matchedRoute = app.headersMap.find((header) => header.pathname.includes(pathname));
|
||||
if (matchedRoute) {
|
||||
for (const header of matchedRoute.headers) {
|
||||
res.setHeader(header.key, header.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (trailingSlash) {
|
||||
case "never": {
|
||||
if (isDirectory && urlPath !== "/" && hasSlash) {
|
||||
pathname = urlPath.slice(0, -1) + (urlQuery ? "?" + urlQuery : "");
|
||||
res.statusCode = 301;
|
||||
res.setHeader("Location", pathname);
|
||||
return res.end();
|
||||
}
|
||||
if (isDirectory && !hasSlash) {
|
||||
pathname = `${urlPath}/index.html`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "ignore": {
|
||||
if (isDirectory && !hasSlash) {
|
||||
pathname = `${urlPath}/index.html`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "always": {
|
||||
if (!hasSlash && !hasFileExtension(urlPath) && !isInternalPath(urlPath)) {
|
||||
pathname = urlPath + "/" + (urlQuery ? "?" + urlQuery : "");
|
||||
res.statusCode = 301;
|
||||
res.setHeader("Location", pathname);
|
||||
return res.end();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
pathname = prependForwardSlash(app.removeBase(pathname));
|
||||
const stream = send(req, pathname, {
|
||||
root: client,
|
||||
dotfiles: pathname.startsWith("/.well-known/") ? "allow" : "deny"
|
||||
});
|
||||
let forwardError = false;
|
||||
stream.on("error", (err) => {
|
||||
if (forwardError) {
|
||||
console.error(err.toString());
|
||||
res.writeHead(500);
|
||||
res.end("Internal server error");
|
||||
return;
|
||||
}
|
||||
ssr();
|
||||
});
|
||||
stream.on("headers", (_res) => {
|
||||
if (pathname.startsWith(`/${options.assets}/`)) {
|
||||
_res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
|
||||
}
|
||||
});
|
||||
stream.on("file", () => {
|
||||
forwardError = true;
|
||||
});
|
||||
stream.pipe(res);
|
||||
} else {
|
||||
ssr();
|
||||
}
|
||||
};
|
||||
}
|
||||
function prependForwardSlash(pth) {
|
||||
return pth.startsWith("/") ? pth : "/" + pth;
|
||||
}
|
||||
export {
|
||||
createStaticHandler
|
||||
};
|
||||
18
dealplustech-astro/node_modules/@astrojs/node/dist/server.d.ts
generated
vendored
Normal file
18
dealplustech-astro/node_modules/@astrojs/node/dist/server.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import './polyfill.js';
|
||||
import type { SSRManifest } from 'astro';
|
||||
import type { Options } from './types.js';
|
||||
export declare function createExports(manifest: SSRManifest, options: Options): {
|
||||
options: Options;
|
||||
handler: import("./types.js").RequestHandler;
|
||||
startServer: () => {
|
||||
server: {
|
||||
host: string;
|
||||
port: number;
|
||||
closed(): Promise<void>;
|
||||
stop(): Promise<void>;
|
||||
server: import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
||||
};
|
||||
done: Promise<void>;
|
||||
};
|
||||
};
|
||||
export declare function start(manifest: SSRManifest, options: Options): void;
|
||||
56
dealplustech-astro/node_modules/@astrojs/node/dist/server.js
generated
vendored
Normal file
56
dealplustech-astro/node_modules/@astrojs/node/dist/server.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import "./polyfill.js";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { NodeApp } from "astro/app/node";
|
||||
import { setGetEnv } from "astro/env/setup";
|
||||
import createMiddleware from "./middleware.js";
|
||||
import { STATIC_HEADERS_FILE } from "./shared.js";
|
||||
import startServer, { createStandaloneHandler } from "./standalone.js";
|
||||
setGetEnv((key) => process.env[key]);
|
||||
function createExports(manifest, options) {
|
||||
const app = new NodeApp(manifest, !options.experimentalDisableStreaming);
|
||||
let headersMap = void 0;
|
||||
if (options.experimentalStaticHeaders) {
|
||||
headersMap = readHeadersJson(manifest.outDir);
|
||||
}
|
||||
if (headersMap) {
|
||||
app.setHeadersMap(headersMap);
|
||||
}
|
||||
options.trailingSlash = manifest.trailingSlash;
|
||||
return {
|
||||
options,
|
||||
handler: options.mode === "middleware" ? createMiddleware(app, options) : createStandaloneHandler(app, options),
|
||||
startServer: () => startServer(app, options)
|
||||
};
|
||||
}
|
||||
function start(manifest, options) {
|
||||
if (options.mode !== "standalone" || process.env.ASTRO_NODE_AUTOSTART === "disabled") {
|
||||
return;
|
||||
}
|
||||
let headersMap = void 0;
|
||||
if (options.experimentalStaticHeaders) {
|
||||
headersMap = readHeadersJson(manifest.outDir);
|
||||
}
|
||||
const app = new NodeApp(manifest, !options.experimentalDisableStreaming);
|
||||
if (headersMap) {
|
||||
app.setHeadersMap(headersMap);
|
||||
}
|
||||
startServer(app, options);
|
||||
}
|
||||
function readHeadersJson(outDir) {
|
||||
let headersMap = void 0;
|
||||
const headersUrl = new URL(STATIC_HEADERS_FILE, outDir);
|
||||
if (existsSync(headersUrl)) {
|
||||
const content = readFileSync(headersUrl, "utf-8");
|
||||
try {
|
||||
headersMap = JSON.parse(content);
|
||||
} catch (e) {
|
||||
console.error("[@astrojs/node] Error parsing _headers.json: " + e.message);
|
||||
console.error("[@astrojs/node] Please make sure your _headers.json is valid JSON.");
|
||||
}
|
||||
}
|
||||
return headersMap;
|
||||
}
|
||||
export {
|
||||
createExports,
|
||||
start
|
||||
};
|
||||
9
dealplustech-astro/node_modules/@astrojs/node/dist/shared.d.ts
generated
vendored
Normal file
9
dealplustech-astro/node_modules/@astrojs/node/dist/shared.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Options } from './types.js';
|
||||
export declare const STATIC_HEADERS_FILE = "_experimentalHeaders.json";
|
||||
/**
|
||||
* Resolves the client directory path at runtime.
|
||||
*
|
||||
* At build time, we know the relative path between server and client directories.
|
||||
* At runtime, we need to find the actual location based on where the server entry is running.
|
||||
*/
|
||||
export declare function resolveClientDir(options: Options): string;
|
||||
21
dealplustech-astro/node_modules/@astrojs/node/dist/shared.js
generated
vendored
Normal file
21
dealplustech-astro/node_modules/@astrojs/node/dist/shared.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import path from "node:path";
|
||||
import url from "node:url";
|
||||
import { appendForwardSlash } from "@astrojs/internal-helpers/path";
|
||||
const STATIC_HEADERS_FILE = "_experimentalHeaders.json";
|
||||
function resolveClientDir(options) {
|
||||
const clientURLRaw = new URL(options.client);
|
||||
const serverURLRaw = new URL(options.server);
|
||||
const rel = path.relative(url.fileURLToPath(serverURLRaw), url.fileURLToPath(clientURLRaw));
|
||||
const serverFolder = path.basename(options.server);
|
||||
let serverEntryFolderURL = path.dirname(import.meta.url);
|
||||
while (!serverEntryFolderURL.endsWith(serverFolder)) {
|
||||
serverEntryFolderURL = path.dirname(serverEntryFolderURL);
|
||||
}
|
||||
const serverEntryURL = serverEntryFolderURL + "/entry.mjs";
|
||||
const clientURL = new URL(appendForwardSlash(rel), serverEntryURL);
|
||||
return url.fileURLToPath(clientURL);
|
||||
}
|
||||
export {
|
||||
STATIC_HEADERS_FILE,
|
||||
resolveClientDir
|
||||
};
|
||||
23
dealplustech-astro/node_modules/@astrojs/node/dist/standalone.d.ts
generated
vendored
Normal file
23
dealplustech-astro/node_modules/@astrojs/node/dist/standalone.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import http from 'node:http';
|
||||
import https from 'node:https';
|
||||
import type { NodeApp } from 'astro/app/node';
|
||||
import type { Options } from './types.js';
|
||||
export declare const hostOptions: (host: Options["host"]) => string;
|
||||
export default function standalone(app: NodeApp, options: Options): {
|
||||
server: {
|
||||
host: string;
|
||||
port: number;
|
||||
closed(): Promise<void>;
|
||||
stop(): Promise<void>;
|
||||
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
||||
};
|
||||
done: Promise<void>;
|
||||
};
|
||||
export declare function createStandaloneHandler(app: NodeApp, options: Options): (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
||||
export declare function createServer(listener: http.RequestListener, host: string, port: number): {
|
||||
host: string;
|
||||
port: number;
|
||||
closed(): Promise<void>;
|
||||
stop(): Promise<void>;
|
||||
server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
||||
};
|
||||
82
dealplustech-astro/node_modules/@astrojs/node/dist/standalone.js
generated
vendored
Normal file
82
dealplustech-astro/node_modules/@astrojs/node/dist/standalone.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import fs from "node:fs";
|
||||
import http from "node:http";
|
||||
import https from "node:https";
|
||||
import enableDestroy from "server-destroy";
|
||||
import { logListeningOn } from "./log-listening-on.js";
|
||||
import { createAppHandler } from "./serve-app.js";
|
||||
import { createStaticHandler } from "./serve-static.js";
|
||||
const hostOptions = (host) => {
|
||||
if (typeof host === "boolean") {
|
||||
return host ? "0.0.0.0" : "localhost";
|
||||
}
|
||||
return host;
|
||||
};
|
||||
function standalone(app, options) {
|
||||
const port = process.env.PORT ? Number(process.env.PORT) : options.port ?? 8080;
|
||||
const host = process.env.HOST ?? hostOptions(options.host);
|
||||
const handler = createStandaloneHandler(app, options);
|
||||
const server = createServer(handler, host, port);
|
||||
server.server.listen(port, host);
|
||||
if (process.env.ASTRO_NODE_LOGGING !== "disabled") {
|
||||
logListeningOn(app.getAdapterLogger(), server.server, host);
|
||||
}
|
||||
return {
|
||||
server,
|
||||
done: server.closed()
|
||||
};
|
||||
}
|
||||
function createStandaloneHandler(app, options) {
|
||||
const appHandler = createAppHandler(app, options);
|
||||
const staticHandler = createStaticHandler(app, options);
|
||||
return (req, res) => {
|
||||
try {
|
||||
decodeURI(req.url);
|
||||
} catch {
|
||||
res.writeHead(400);
|
||||
res.end("Bad request.");
|
||||
return;
|
||||
}
|
||||
staticHandler(req, res, () => appHandler(req, res));
|
||||
};
|
||||
}
|
||||
function createServer(listener, host, port) {
|
||||
let httpServer;
|
||||
if (process.env.SERVER_CERT_PATH && process.env.SERVER_KEY_PATH) {
|
||||
httpServer = https.createServer(
|
||||
{
|
||||
key: fs.readFileSync(process.env.SERVER_KEY_PATH),
|
||||
cert: fs.readFileSync(process.env.SERVER_CERT_PATH)
|
||||
},
|
||||
listener
|
||||
);
|
||||
} else {
|
||||
httpServer = http.createServer(listener);
|
||||
}
|
||||
enableDestroy(httpServer);
|
||||
const closed = new Promise((resolve, reject) => {
|
||||
httpServer.addListener("close", resolve);
|
||||
httpServer.addListener("error", reject);
|
||||
});
|
||||
const previewable = {
|
||||
host,
|
||||
port,
|
||||
closed() {
|
||||
return closed;
|
||||
},
|
||||
async stop() {
|
||||
await new Promise((resolve, reject) => {
|
||||
httpServer.destroy((err) => err ? reject(err) : resolve(void 0));
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
server: httpServer,
|
||||
...previewable
|
||||
};
|
||||
}
|
||||
export {
|
||||
createServer,
|
||||
createStandaloneHandler,
|
||||
standalone as default,
|
||||
hostOptions
|
||||
};
|
||||
47
dealplustech-astro/node_modules/@astrojs/node/dist/types.d.ts
generated
vendored
Normal file
47
dealplustech-astro/node_modules/@astrojs/node/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http';
|
||||
import type { SSRManifest } from 'astro';
|
||||
export interface UserOptions {
|
||||
/**
|
||||
* Specifies the mode that the adapter builds to.
|
||||
*
|
||||
* - 'middleware' - Build to middleware, to be used within another Node.js server, such as Express.
|
||||
* - 'standalone' - Build to a standalone server. The server starts up just by running the built script.
|
||||
*/
|
||||
mode: 'middleware' | 'standalone';
|
||||
/**
|
||||
* Disables HTML streaming. This is useful for example if there are constraints from your host.
|
||||
*/
|
||||
experimentalDisableStreaming?: boolean;
|
||||
/**
|
||||
* If enabled, the adapter will save [static headers in the framework API file](https://docs.netlify.com/frameworks-api/#headers).
|
||||
*
|
||||
* Here the list of the headers that are added:
|
||||
* - The CSP header of the static pages is added when CSP support is enabled.
|
||||
*/
|
||||
experimentalStaticHeaders?: boolean;
|
||||
/**
|
||||
* The host that should be used if the server needs to fetch the prerendered error page.
|
||||
* If not provided, this will default to the host of the server. This should be set if the server
|
||||
* should fetch prerendered error pages from a different host than the public URL of the server.
|
||||
* This is useful for example if the server is behind a reverse proxy or a load balancer, or if
|
||||
* static files are hosted on a different domain. Do not include a path in the URL: it will be ignored.
|
||||
*/
|
||||
experimentalErrorPageHost?: string | URL;
|
||||
}
|
||||
export interface Options extends UserOptions {
|
||||
host: string | boolean;
|
||||
port: number;
|
||||
server: string;
|
||||
client: string;
|
||||
assets: string;
|
||||
trailingSlash?: SSRManifest['trailingSlash'];
|
||||
experimentalStaticHeaders: boolean;
|
||||
}
|
||||
export type RequestHandler = (...args: RequestHandlerParams) => void | Promise<void>;
|
||||
type RequestHandlerParams = [
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
next?: (err?: unknown) => void,
|
||||
locals?: object
|
||||
];
|
||||
export {};
|
||||
0
dealplustech-astro/node_modules/@astrojs/node/dist/types.js
generated
vendored
Normal file
0
dealplustech-astro/node_modules/@astrojs/node/dist/types.js
generated
vendored
Normal file
60
dealplustech-astro/node_modules/@astrojs/node/package.json
generated
vendored
Normal file
60
dealplustech-astro/node_modules/@astrojs/node/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "@astrojs/node",
|
||||
"description": "Deploy your site to a Node.js server",
|
||||
"version": "9.5.4",
|
||||
"type": "module",
|
||||
"types": "./dist/index.d.ts",
|
||||
"author": "withastro",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/withastro/astro.git",
|
||||
"directory": "packages/integrations/node"
|
||||
},
|
||||
"keywords": [
|
||||
"withastro",
|
||||
"astro-adapter"
|
||||
],
|
||||
"bugs": "https://github.com/withastro/astro/issues",
|
||||
"homepage": "https://docs.astro.build/en/guides/integrations-guide/node/",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./server.js": "./dist/server.js",
|
||||
"./preview.js": "./dist/preview.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"send": "^1.2.1",
|
||||
"server-destroy": "^1.0.1",
|
||||
"@astrojs/internal-helpers": "0.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"astro": "^5.17.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.6",
|
||||
"@types/send": "^0.17.6",
|
||||
"@types/server-destroy": "^1.0.4",
|
||||
"cheerio": "1.1.2",
|
||||
"devalue": "^5.6.2",
|
||||
"express": "^4.22.1",
|
||||
"fastify": "^5.7.0",
|
||||
"@fastify/middie": "^9.1.0",
|
||||
"@fastify/static": "^9.0.0",
|
||||
"node-mocks-http": "^1.17.2",
|
||||
"astro": "5.17.3",
|
||||
"astro-scripts": "0.0.14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"provenance": true
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
||||
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
||||
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
||||
"test": "astro-scripts test \"test/**/*.test.js\""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user