@cedarjs/fastify-web 5.0.4-next.167 → 5.0.4
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/dist/helpers.js +26 -2
- package/dist/web.js +55 -19
- package/package.json +9 -9
package/dist/helpers.js
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var helpers_exports = {};
|
|
20
|
+
__export(helpers_exports, {
|
|
21
|
+
coerceRootPath: () => coerceRootPath
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
1
24
|
function coerceRootPath(path) {
|
|
2
25
|
const prefix = !path.startsWith("/") ? "/" : "";
|
|
3
26
|
const suffix = !path.endsWith("/") ? "/" : "";
|
|
4
27
|
return `${prefix}${path}${suffix}`;
|
|
5
28
|
}
|
|
6
|
-
export
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
7
31
|
coerceRootPath
|
|
8
|
-
};
|
|
32
|
+
});
|
package/dist/web.js
CHANGED
|
@@ -1,11 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
1
30
|
// src/web.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
31
|
+
var web_exports = {};
|
|
32
|
+
__export(web_exports, {
|
|
33
|
+
coerceRootPath: () => coerceRootPath,
|
|
34
|
+
redwoodFastifyWeb: () => redwoodFastifyWeb
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(web_exports);
|
|
37
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_http_proxy = __toESM(require("@fastify/http-proxy"));
|
|
40
|
+
var import_static = __toESM(require("@fastify/static"));
|
|
41
|
+
var import_url_data = __toESM(require("@fastify/url-data"));
|
|
42
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
43
|
+
var import_project_config2 = require("@cedarjs/project-config");
|
|
9
44
|
|
|
10
45
|
// src/helpers.ts
|
|
11
46
|
function coerceRootPath(path2) {
|
|
@@ -15,13 +50,13 @@ function coerceRootPath(path2) {
|
|
|
15
50
|
}
|
|
16
51
|
|
|
17
52
|
// src/resolveOptions.ts
|
|
18
|
-
|
|
53
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
19
54
|
function resolveOptions(options) {
|
|
20
55
|
const redwoodOptions = options.redwood ?? {};
|
|
21
56
|
const flags = {
|
|
22
57
|
shouldRegisterApiUrl: false
|
|
23
58
|
};
|
|
24
|
-
redwoodOptions.apiUrl ??= getConfig().web.apiUrl;
|
|
59
|
+
redwoodOptions.apiUrl ??= (0, import_project_config.getConfig)().web.apiUrl;
|
|
25
60
|
const apiUrlIsFullyQualifiedUrl = isFullyQualifiedUrl(redwoodOptions.apiUrl);
|
|
26
61
|
if (redwoodOptions.apiHost && !redwoodOptions.apiProxyTarget) {
|
|
27
62
|
redwoodOptions.apiProxyTarget = redwoodOptions.apiHost;
|
|
@@ -62,10 +97,10 @@ function isFullyQualifiedUrl(url) {
|
|
|
62
97
|
// src/web.ts
|
|
63
98
|
async function redwoodFastifyWeb(fastify, opts) {
|
|
64
99
|
const { redwoodOptions, flags } = resolveOptions(opts);
|
|
65
|
-
fastify.register(
|
|
66
|
-
fastify.register(
|
|
100
|
+
fastify.register(import_url_data.default);
|
|
101
|
+
fastify.register(import_static.default, { root: (0, import_project_config2.getPaths)().web.dist });
|
|
67
102
|
if (redwoodOptions.apiProxyTarget) {
|
|
68
|
-
fastify.register(
|
|
103
|
+
fastify.register(import_http_proxy.default, {
|
|
69
104
|
prefix: redwoodOptions.apiUrl,
|
|
70
105
|
upstream: redwoodOptions.apiProxyTarget,
|
|
71
106
|
disableCache: true,
|
|
@@ -98,8 +133,8 @@ async function redwoodFastifyWeb(fastify, opts) {
|
|
|
98
133
|
fastify.all(apiUrlWarningPath, apiUrlHandler);
|
|
99
134
|
fastify.all(`${apiUrlWarningPath}*`, apiUrlHandler);
|
|
100
135
|
}
|
|
101
|
-
const prerenderedFiles = await
|
|
102
|
-
cwd: getPaths().web.dist,
|
|
136
|
+
const prerenderedFiles = await (0, import_fast_glob.default)("**/*.html", {
|
|
137
|
+
cwd: (0, import_project_config2.getPaths)().web.dist,
|
|
103
138
|
ignore: ["index.html", "200.html", "404.html"]
|
|
104
139
|
});
|
|
105
140
|
for (const prerenderedFile of prerenderedFiles) {
|
|
@@ -109,11 +144,11 @@ async function redwoodFastifyWeb(fastify, opts) {
|
|
|
109
144
|
reply.sendFile(prerenderedFile);
|
|
110
145
|
});
|
|
111
146
|
}
|
|
112
|
-
const prerenderIndexPath =
|
|
113
|
-
const fallbackIndexPath =
|
|
147
|
+
const prerenderIndexPath = import_path.default.join((0, import_project_config2.getPaths)().web.dist, "200.html");
|
|
148
|
+
const fallbackIndexPath = import_node_fs.default.existsSync(prerenderIndexPath) ? "200.html" : "index.html";
|
|
114
149
|
fastify.setNotFoundHandler({}, (req, reply) => {
|
|
115
150
|
const urlData = req.urlData();
|
|
116
|
-
const requestHasExtension = !!
|
|
151
|
+
const requestHasExtension = !!import_path.default.extname(urlData.path ?? "");
|
|
117
152
|
if (requestHasExtension && urlData.path?.startsWith("/assets/")) {
|
|
118
153
|
reply.code(404);
|
|
119
154
|
return reply.send("Not Found");
|
|
@@ -122,7 +157,8 @@ async function redwoodFastifyWeb(fastify, opts) {
|
|
|
122
157
|
return reply.sendFile(fallbackIndexPath);
|
|
123
158
|
});
|
|
124
159
|
}
|
|
125
|
-
export
|
|
160
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
+
0 && (module.exports = {
|
|
126
162
|
coerceRootPath,
|
|
127
163
|
redwoodFastifyWeb
|
|
128
|
-
};
|
|
164
|
+
});
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/fastify-web",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
7
|
"directory": "packages/adapters/fastify/web"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "commonjs",
|
|
11
11
|
"main": "./dist/web.js",
|
|
12
12
|
"types": "./dist/web.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "node ./build.mts",
|
|
17
|
+
"build": "node ./build.mts && yarn build:types",
|
|
18
18
|
"build:pack": "yarn pack -o cedarjs-fastify-web.tgz",
|
|
19
|
-
"build:types": "tsc --build --verbose
|
|
19
|
+
"build:types": "tsc --build --verbose",
|
|
20
20
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"test:watch": "vitest watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cedarjs/project-config": "5.0.4
|
|
26
|
-
"@fastify/http-proxy": "11.
|
|
25
|
+
"@cedarjs/project-config": "5.0.4",
|
|
26
|
+
"@fastify/http-proxy": "11.5.0",
|
|
27
27
|
"@fastify/static": "8.3.0",
|
|
28
28
|
"@fastify/url-data": "6.0.3",
|
|
29
29
|
"fast-glob": "3.3.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@cedarjs/framework-tools": "5.0.4
|
|
33
|
-
"fastify": "5.
|
|
32
|
+
"@cedarjs/framework-tools": "5.0.4",
|
|
33
|
+
"fastify": "5.8.5",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
|
-
"vitest": "
|
|
35
|
+
"vitest": "3.2.6"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=24"
|