@cedarjs/fastify-web 5.0.6 → 5.0.7-next.186

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 CHANGED
@@ -1,32 +1,8 @@
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);
24
1
  function coerceRootPath(path) {
25
2
  const prefix = !path.startsWith("/") ? "/" : "";
26
3
  const suffix = !path.endsWith("/") ? "/" : "";
27
4
  return `${prefix}${path}${suffix}`;
28
5
  }
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
6
+ export {
31
7
  coerceRootPath
32
- });
8
+ };
package/dist/web.js CHANGED
@@ -1,46 +1,11 @@
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
-
30
1
  // src/web.ts
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");
2
+ import fs from "node:fs";
3
+ import path from "path";
4
+ import httpProxy from "@fastify/http-proxy";
5
+ import fastifyStatic from "@fastify/static";
6
+ import fastifyUrlData from "@fastify/url-data";
7
+ import fg from "fast-glob";
8
+ import { getPaths } from "@cedarjs/project-config";
44
9
 
45
10
  // src/helpers.ts
46
11
  function coerceRootPath(path2) {
@@ -50,13 +15,13 @@ function coerceRootPath(path2) {
50
15
  }
51
16
 
52
17
  // src/resolveOptions.ts
53
- var import_project_config = require("@cedarjs/project-config");
18
+ import { getConfig } from "@cedarjs/project-config";
54
19
  function resolveOptions(options) {
55
20
  const redwoodOptions = options.redwood ?? {};
56
21
  const flags = {
57
22
  shouldRegisterApiUrl: false
58
23
  };
59
- redwoodOptions.apiUrl ??= (0, import_project_config.getConfig)().web.apiUrl;
24
+ redwoodOptions.apiUrl ??= getConfig().web.apiUrl;
60
25
  const apiUrlIsFullyQualifiedUrl = isFullyQualifiedUrl(redwoodOptions.apiUrl);
61
26
  if (redwoodOptions.apiHost && !redwoodOptions.apiProxyTarget) {
62
27
  redwoodOptions.apiProxyTarget = redwoodOptions.apiHost;
@@ -97,10 +62,10 @@ function isFullyQualifiedUrl(url) {
97
62
  // src/web.ts
98
63
  async function redwoodFastifyWeb(fastify, opts) {
99
64
  const { redwoodOptions, flags } = resolveOptions(opts);
100
- fastify.register(import_url_data.default);
101
- fastify.register(import_static.default, { root: (0, import_project_config2.getPaths)().web.dist });
65
+ fastify.register(fastifyUrlData);
66
+ fastify.register(fastifyStatic, { root: getPaths().web.dist });
102
67
  if (redwoodOptions.apiProxyTarget) {
103
- fastify.register(import_http_proxy.default, {
68
+ fastify.register(httpProxy, {
104
69
  prefix: redwoodOptions.apiUrl,
105
70
  upstream: redwoodOptions.apiProxyTarget,
106
71
  disableCache: true,
@@ -133,8 +98,8 @@ async function redwoodFastifyWeb(fastify, opts) {
133
98
  fastify.all(apiUrlWarningPath, apiUrlHandler);
134
99
  fastify.all(`${apiUrlWarningPath}*`, apiUrlHandler);
135
100
  }
136
- const prerenderedFiles = await (0, import_fast_glob.default)("**/*.html", {
137
- cwd: (0, import_project_config2.getPaths)().web.dist,
101
+ const prerenderedFiles = await fg("**/*.html", {
102
+ cwd: getPaths().web.dist,
138
103
  ignore: ["index.html", "200.html", "404.html"]
139
104
  });
140
105
  for (const prerenderedFile of prerenderedFiles) {
@@ -144,11 +109,11 @@ async function redwoodFastifyWeb(fastify, opts) {
144
109
  reply.sendFile(prerenderedFile);
145
110
  });
146
111
  }
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";
112
+ const prerenderIndexPath = path.join(getPaths().web.dist, "200.html");
113
+ const fallbackIndexPath = fs.existsSync(prerenderIndexPath) ? "200.html" : "index.html";
149
114
  fastify.setNotFoundHandler({}, (req, reply) => {
150
115
  const urlData = req.urlData();
151
- const requestHasExtension = !!import_path.default.extname(urlData.path ?? "");
116
+ const requestHasExtension = !!path.extname(urlData.path ?? "");
152
117
  if (requestHasExtension && urlData.path?.startsWith("/assets/")) {
153
118
  reply.code(404);
154
119
  return reply.send("Not Found");
@@ -157,8 +122,7 @@ async function redwoodFastifyWeb(fastify, opts) {
157
122
  return reply.sendFile(fallbackIndexPath);
158
123
  });
159
124
  }
160
- // Annotate the CommonJS export names for ESM import in node:
161
- 0 && (module.exports = {
125
+ export {
162
126
  coerceRootPath,
163
127
  redwoodFastifyWeb
164
- });
128
+ };
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "name": "@cedarjs/fastify-web",
3
- "version": "5.0.6",
3
+ "version": "5.0.7-next.186",
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": "commonjs",
10
+ "type": "module",
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 && yarn build:types",
17
+ "build": "node ./build.mts",
18
18
  "build:pack": "yarn pack -o cedarjs-fastify-web.tgz",
19
- "build:types": "tsc --build --verbose",
19
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
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.6",
26
- "@fastify/http-proxy": "11.5.0",
25
+ "@cedarjs/project-config": "5.0.7-next.186",
26
+ "@fastify/http-proxy": "11.6.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.6",
33
- "fastify": "5.8.5",
32
+ "@cedarjs/framework-tools": "5.0.7-next.186",
33
+ "fastify": "5.10.0",
34
34
  "typescript": "5.9.3",
35
- "vitest": "3.2.6"
35
+ "vitest": "4.1.10"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=24"