@cedarjs/web-server 5.0.4-next.167 → 5.0.4-rc.3

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/bin.js CHANGED
@@ -1,26 +1,37 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __esm = (fn, res, err) => function __init() {
4
- if (err) throw err[0];
5
- try {
6
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
- } catch (e) {
8
- throw err = [e], e;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __esm = (fn, res) => function __init() {
10
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
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 });
9
17
  }
18
+ return to;
10
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
+ ));
11
28
 
12
29
  // src/webServer.ts
13
- import fs from "node:fs";
14
- import path from "node:path";
15
- import ansis from "ansis";
16
- import Fastify from "fastify";
17
- import { redwoodFastifyWeb } from "@cedarjs/fastify-web";
18
- import { getConfig, getPaths } from "@cedarjs/project-config";
19
30
  async function serveWeb(options = {}) {
20
31
  const start = Date.now();
21
- console.log(ansis.dim.italic("Starting Web Server..."));
22
- const distIndexExists = fs.existsSync(
23
- path.join(getPaths().web.dist, "index.html")
32
+ console.log(import_ansis.default.dim.italic("Starting Web Server..."));
33
+ const distIndexExists = import_node_fs.default.existsSync(
34
+ import_node_path.default.join((0, import_project_config.getPaths)().web.dist, "index.html")
24
35
  );
25
36
  if (!distIndexExists) {
26
37
  throw new Error(
@@ -30,32 +41,39 @@ async function serveWeb(options = {}) {
30
41
  if (process.env.REDWOOD_WEB_PORT) {
31
42
  options.port ??= parseInt(process.env.REDWOOD_WEB_PORT);
32
43
  }
33
- options.port ??= getConfig().web.port;
44
+ options.port ??= (0, import_project_config.getConfig)().web.port;
34
45
  options.host ??= process.env.REDWOOD_WEB_HOST;
35
- options.host ??= getConfig().web.host;
46
+ options.host ??= (0, import_project_config.getConfig)().web.host;
36
47
  options.host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
37
48
  if (process.env.NODE_ENV === "production" && options.host !== "0.0.0.0") {
38
49
  console.warn(
39
50
  `Warning: host '${options.host}' may need to be '0.0.0.0' in production for containerized deployments`
40
51
  );
41
52
  }
42
- const fastify = Fastify({
53
+ const fastify = (0, import_fastify.default)({
43
54
  requestTimeout: 15e3,
44
55
  logger: {
45
56
  level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === "development" ? "debug" : "warn")
46
57
  }
47
58
  });
48
- fastify.register(redwoodFastifyWeb, { redwood: options });
59
+ fastify.register(import_fastify_web.redwoodFastifyWeb, { redwood: options });
49
60
  const address = await fastify.listen({
50
61
  port: options.port,
51
62
  host: options.host
52
63
  });
53
- console.log(ansis.dim.italic("Took " + (Date.now() - start) + " ms"));
54
- console.log(`Web server listening at ${ansis.green(address)}`);
64
+ console.log(import_ansis.default.dim.italic("Took " + (Date.now() - start) + " ms"));
65
+ console.log(`Web server listening at ${import_ansis.default.green(address)}`);
55
66
  }
67
+ var import_node_fs, import_node_path, import_ansis, import_fastify, import_fastify_web, import_project_config;
56
68
  var init_webServer = __esm({
57
69
  "src/webServer.ts"() {
58
70
  "use strict";
71
+ import_node_fs = __toESM(require("node:fs"));
72
+ import_node_path = __toESM(require("node:path"));
73
+ import_ansis = __toESM(require("ansis"));
74
+ import_fastify = __toESM(require("fastify"));
75
+ import_fastify_web = require("@cedarjs/fastify-web");
76
+ import_project_config = require("@cedarjs/project-config");
59
77
  }
60
78
  });
61
79
 
@@ -76,11 +94,11 @@ var init_cliConfigHandler = __esm({
76
94
  });
77
95
 
78
96
  // src/bin.ts
79
- import path2 from "path";
80
- import { config } from "dotenv-defaults";
81
- import { hideBin } from "yargs/helpers";
82
- import yargs from "yargs/yargs";
83
- import { getPaths as getPaths2 } from "@cedarjs/project-config";
97
+ var import_path = __toESM(require("path"));
98
+ var import_dotenv_defaults = require("dotenv-defaults");
99
+ var import_helpers = require("yargs/helpers");
100
+ var import_yargs = __toESM(require("yargs/yargs"));
101
+ var import_project_config2 = require("@cedarjs/project-config");
84
102
 
85
103
  // src/cliConfig.ts
86
104
  var description = "Start a server for serving the web side";
@@ -111,15 +129,15 @@ function builder(yargs2) {
111
129
  // src/bin.ts
112
130
  init_cliConfigHandler();
113
131
  if (!process.env.CEDAR_ENV_FILES_LOADED) {
114
- config({
115
- path: path2.join(getPaths2().base, ".env"),
116
- defaults: path2.join(getPaths2().base, ".env.defaults"),
132
+ (0, import_dotenv_defaults.config)({
133
+ path: import_path.default.join((0, import_project_config2.getPaths)().base, ".env"),
134
+ defaults: import_path.default.join((0, import_project_config2.getPaths)().base, ".env.defaults"),
117
135
  multiline: true
118
136
  });
119
137
  process.env.CEDAR_ENV_FILES_LOADED = "true";
120
138
  }
121
139
  process.env.NODE_ENV ??= "production";
122
- yargs(hideBin(process.argv)).scriptName("cedar-web-server").alias("h", "help").alias("v", "version").strict().example(
140
+ (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).scriptName("cedar-web-server").alias("h", "help").alias("v", "version").strict().example(
123
141
  "yarn $0 --api-url=/api --api-proxy-target=https://api.redwood.horse",
124
142
  "Start the web server and proxy requests made to '/api' to 'https://api.redwood.horse'"
125
143
  ).example(
package/dist/cliConfig.js CHANGED
@@ -1,3 +1,38 @@
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
+ var cliConfig_exports = {};
30
+ __export(cliConfig_exports, {
31
+ builder: () => builder,
32
+ description: () => description,
33
+ handler: () => handler
34
+ });
35
+ module.exports = __toCommonJS(cliConfig_exports);
1
36
  const description = "Start a server for serving the web side";
2
37
  function builder(yargs) {
3
38
  yargs.options({
@@ -26,8 +61,9 @@ async function handler(options) {
26
61
  const { handler: handler2 } = await import("./cliConfigHandler.js");
27
62
  await handler2(options);
28
63
  }
29
- export {
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
30
66
  builder,
31
67
  description,
32
68
  handler
33
- };
69
+ });
@@ -1,12 +1,36 @@
1
- import { serveWeb } from "./webServer.js";
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 cliConfigHandler_exports = {};
20
+ __export(cliConfigHandler_exports, {
21
+ handler: () => handler
22
+ });
23
+ module.exports = __toCommonJS(cliConfigHandler_exports);
24
+ var import_webServer = require("./webServer.js");
2
25
  async function handler(options) {
3
26
  try {
4
- await serveWeb(options);
27
+ await (0, import_webServer.serveWeb)(options);
5
28
  } catch (error) {
6
29
  process.exitCode ||= 1;
7
30
  console.error(`Error: ${error.message}`);
8
31
  }
9
32
  }
10
- export {
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
11
35
  handler
12
- };
36
+ });
package/dist/webServer.js CHANGED
@@ -1,14 +1,47 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import ansis from "ansis";
4
- import Fastify from "fastify";
5
- import { redwoodFastifyWeb } from "@cedarjs/fastify-web";
6
- import { getConfig, getPaths } from "@cedarjs/project-config";
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
+ var webServer_exports = {};
30
+ __export(webServer_exports, {
31
+ serveWeb: () => serveWeb
32
+ });
33
+ module.exports = __toCommonJS(webServer_exports);
34
+ var import_node_fs = __toESM(require("node:fs"));
35
+ var import_node_path = __toESM(require("node:path"));
36
+ var import_ansis = __toESM(require("ansis"));
37
+ var import_fastify = __toESM(require("fastify"));
38
+ var import_fastify_web = require("@cedarjs/fastify-web");
39
+ var import_project_config = require("@cedarjs/project-config");
7
40
  async function serveWeb(options = {}) {
8
41
  const start = Date.now();
9
- console.log(ansis.dim.italic("Starting Web Server..."));
10
- const distIndexExists = fs.existsSync(
11
- path.join(getPaths().web.dist, "index.html")
42
+ console.log(import_ansis.default.dim.italic("Starting Web Server..."));
43
+ const distIndexExists = import_node_fs.default.existsSync(
44
+ import_node_path.default.join((0, import_project_config.getPaths)().web.dist, "index.html")
12
45
  );
13
46
  if (!distIndexExists) {
14
47
  throw new Error(
@@ -18,29 +51,30 @@ async function serveWeb(options = {}) {
18
51
  if (process.env.REDWOOD_WEB_PORT) {
19
52
  options.port ??= parseInt(process.env.REDWOOD_WEB_PORT);
20
53
  }
21
- options.port ??= getConfig().web.port;
54
+ options.port ??= (0, import_project_config.getConfig)().web.port;
22
55
  options.host ??= process.env.REDWOOD_WEB_HOST;
23
- options.host ??= getConfig().web.host;
56
+ options.host ??= (0, import_project_config.getConfig)().web.host;
24
57
  options.host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
25
58
  if (process.env.NODE_ENV === "production" && options.host !== "0.0.0.0") {
26
59
  console.warn(
27
60
  `Warning: host '${options.host}' may need to be '0.0.0.0' in production for containerized deployments`
28
61
  );
29
62
  }
30
- const fastify = Fastify({
63
+ const fastify = (0, import_fastify.default)({
31
64
  requestTimeout: 15e3,
32
65
  logger: {
33
66
  level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === "development" ? "debug" : "warn")
34
67
  }
35
68
  });
36
- fastify.register(redwoodFastifyWeb, { redwood: options });
69
+ fastify.register(import_fastify_web.redwoodFastifyWeb, { redwood: options });
37
70
  const address = await fastify.listen({
38
71
  port: options.port,
39
72
  host: options.host
40
73
  });
41
- console.log(ansis.dim.italic("Took " + (Date.now() - start) + " ms"));
42
- console.log(`Web server listening at ${ansis.green(address)}`);
74
+ console.log(import_ansis.default.dim.italic("Took " + (Date.now() - start) + " ms"));
75
+ console.log(`Web server listening at ${import_ansis.default.green(address)}`);
43
76
  }
44
- export {
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
45
79
  serveWeb
46
- };
80
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/web-server",
3
- "version": "5.0.4-next.167",
3
+ "version": "5.0.4-rc.3",
4
4
  "description": "CedarJS's server for the Web side",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  "directory": "packages/web-server"
9
9
  },
10
10
  "license": "MIT",
11
- "type": "module",
11
+ "type": "commonjs",
12
12
  "main": "./dist/cliConfig.js",
13
13
  "types": "./dist/cliConfig.d.ts",
14
14
  "bin": {
@@ -19,23 +19,23 @@
19
19
  "dist"
20
20
  ],
21
21
  "scripts": {
22
- "build": "node ./build.mts",
22
+ "build": "node ./build.mts && yarn build:types",
23
23
  "build:pack": "yarn pack -o cedarjs-web-server.tgz",
24
- "build:types": "tsc --build --verbose ./tsconfig.build.json",
24
+ "build:types": "tsc --build --verbose",
25
25
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"",
26
26
  "fix:permissions": "chmod +x dist/index.js; chmod +x dist/watch.js",
27
27
  "prepublishOnly": "NODE_ENV=production yarn build"
28
28
  },
29
29
  "dependencies": {
30
- "@cedarjs/fastify-web": "5.0.4-next.167",
31
- "@cedarjs/project-config": "5.0.4-next.167",
32
- "ansis": "4.3.1",
30
+ "@cedarjs/fastify-web": "5.0.4-rc.3",
31
+ "@cedarjs/project-config": "5.0.4-rc.3",
32
+ "ansis": "4.2.0",
33
33
  "dotenv-defaults": "5.0.2",
34
- "fastify": "5.10.0",
34
+ "fastify": "5.8.5",
35
35
  "yargs": "17.7.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@cedarjs/framework-tools": "5.0.4-next.167",
38
+ "@cedarjs/framework-tools": "5.0.4-rc.3",
39
39
  "typescript": "5.9.3"
40
40
  },
41
41
  "engines": {