@cedarjs/api-server 6.0.0-canary.2816 → 6.0.0-canary.2819
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 +39 -11
- package/dist/bothCLIConfigHandler.d.ts.map +1 -1
- package/dist/bothCLIConfigHandler.js +2 -2
- package/dist/cliHelpers.d.ts +21 -4
- package/dist/cliHelpers.d.ts.map +1 -1
- package/dist/cliHelpers.js +37 -9
- package/package.json +9 -9
package/dist/bin.js
CHANGED
|
@@ -15,27 +15,55 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
// src/cliHelpers.ts
|
|
18
|
-
import { getConfig } from "@cedarjs/project-config";
|
|
19
|
-
function getAPIHost() {
|
|
20
|
-
let host =
|
|
18
|
+
import { getConfig, parsePort, readEnvVar } from "@cedarjs/project-config";
|
|
19
|
+
function getAPIHost({ isPublicSide = false } = {}) {
|
|
20
|
+
let host = readEnvVar("CEDAR_API_HOST", {
|
|
21
|
+
deprecatedAlias: "REDWOOD_API_HOST"
|
|
22
|
+
});
|
|
23
|
+
if (isPublicSide) {
|
|
24
|
+
host ??= process.env.HOST;
|
|
25
|
+
}
|
|
21
26
|
host ??= getConfig().api.host;
|
|
22
27
|
host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
|
|
23
28
|
return host;
|
|
24
29
|
}
|
|
25
|
-
function getAPIPort() {
|
|
26
|
-
|
|
30
|
+
function getAPIPort({ isPublicSide = false } = {}) {
|
|
31
|
+
const apiPort = readEnvVar("CEDAR_API_PORT", {
|
|
32
|
+
deprecatedAlias: "REDWOOD_API_PORT"
|
|
33
|
+
});
|
|
34
|
+
if (apiPort) {
|
|
35
|
+
return parsePort(apiPort, "CEDAR_API_PORT");
|
|
36
|
+
}
|
|
37
|
+
if (isPublicSide && process.env.PORT) {
|
|
38
|
+
return parsePort(process.env.PORT, "PORT");
|
|
39
|
+
}
|
|
40
|
+
return getConfig().api.port;
|
|
27
41
|
}
|
|
28
42
|
function getAPIRootPath() {
|
|
29
43
|
return process.env.CEDAR_API_ROOT_PATH ?? "/";
|
|
30
44
|
}
|
|
31
|
-
function getWebHost() {
|
|
32
|
-
let host =
|
|
45
|
+
function getWebHost({ isPublicSide = false } = {}) {
|
|
46
|
+
let host = readEnvVar("CEDAR_WEB_HOST", {
|
|
47
|
+
deprecatedAlias: "REDWOOD_WEB_HOST"
|
|
48
|
+
});
|
|
49
|
+
if (isPublicSide) {
|
|
50
|
+
host ??= process.env.HOST;
|
|
51
|
+
}
|
|
33
52
|
host ??= getConfig().web.host;
|
|
34
53
|
host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
|
|
35
54
|
return host;
|
|
36
55
|
}
|
|
37
|
-
function getWebPort() {
|
|
38
|
-
|
|
56
|
+
function getWebPort({ isPublicSide = false } = {}) {
|
|
57
|
+
const webPort = readEnvVar("CEDAR_WEB_PORT", {
|
|
58
|
+
deprecatedAlias: "REDWOOD_WEB_PORT"
|
|
59
|
+
});
|
|
60
|
+
if (webPort) {
|
|
61
|
+
return parsePort(webPort, "CEDAR_WEB_PORT");
|
|
62
|
+
}
|
|
63
|
+
if (isPublicSide && process.env.PORT) {
|
|
64
|
+
return parsePort(process.env.PORT, "PORT");
|
|
65
|
+
}
|
|
66
|
+
return getConfig().web.port;
|
|
39
67
|
}
|
|
40
68
|
var init_cliHelpers = __esm({
|
|
41
69
|
"src/cliHelpers.ts"() {
|
|
@@ -805,8 +833,8 @@ import { redwoodFastifyWeb, coerceRootPath as coerceRootPath5 } from "@cedarjs/f
|
|
|
805
833
|
async function handler2(options) {
|
|
806
834
|
const timeStart = Date.now();
|
|
807
835
|
console.log(ansis4.dim.italic("Starting API and Web Servers..."));
|
|
808
|
-
options.webHost ??= getWebHost();
|
|
809
|
-
options.webPort ??= getWebPort();
|
|
836
|
+
options.webHost ??= getWebHost({ isPublicSide: true });
|
|
837
|
+
options.webPort ??= getWebPort({ isPublicSide: true });
|
|
810
838
|
options.apiHost ??= getAPIHost();
|
|
811
839
|
options.apiPort ??= getAPIPort();
|
|
812
840
|
options.apiRootPath = coerceRootPath5(options.apiRootPath ?? "/");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bothCLIConfigHandler.d.ts","sourceRoot":"","sources":["../src/bothCLIConfigHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,wBAAsB,OAAO,CAAC,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"bothCLIConfigHandler.d.ts","sourceRoot":"","sources":["../src/bothCLIConfigHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,wBAAsB,OAAO,CAAC,OAAO,EAAE,iBAAiB,iBAsEvD"}
|
|
@@ -6,8 +6,8 @@ import { createFastifyInstance } from "./fastify.js";
|
|
|
6
6
|
async function handler(options) {
|
|
7
7
|
const timeStart = Date.now();
|
|
8
8
|
console.log(ansis.dim.italic("Starting API and Web Servers..."));
|
|
9
|
-
options.webHost ??= getWebHost();
|
|
10
|
-
options.webPort ??= getWebPort();
|
|
9
|
+
options.webHost ??= getWebHost({ isPublicSide: true });
|
|
10
|
+
options.webPort ??= getWebPort({ isPublicSide: true });
|
|
11
11
|
options.apiHost ??= getAPIHost();
|
|
12
12
|
options.apiPort ??= getAPIPort();
|
|
13
13
|
options.apiRootPath = coerceRootPath(options.apiRootPath ?? "/");
|
package/dist/cliHelpers.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface SideOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether this side receives the deployment's public traffic.
|
|
4
|
+
*
|
|
5
|
+
* Container hosts (Railway, Render, Fly.io, Cloud Run, Heroku) tell an app
|
|
6
|
+
* which host and port to bind with the `HOST` and `PORT` env vars. Only the
|
|
7
|
+
* side serving public traffic falls back to them — when the api and web
|
|
8
|
+
* servers run in the same deployment they would otherwise both bind to
|
|
9
|
+
* `PORT` and collide.
|
|
10
|
+
*
|
|
11
|
+
* The web side is the public one whenever both sides are served together,
|
|
12
|
+
* because it proxies api requests. The api side is only public when it is
|
|
13
|
+
* served on its own.
|
|
14
|
+
*/
|
|
15
|
+
isPublicSide?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function getAPIHost({ isPublicSide }?: SideOptions): string;
|
|
18
|
+
export declare function getAPIPort({ isPublicSide }?: SideOptions): number;
|
|
3
19
|
export declare function getAPIRootPath(): string;
|
|
4
|
-
export declare function getWebHost(): string;
|
|
5
|
-
export declare function getWebPort(): number;
|
|
20
|
+
export declare function getWebHost({ isPublicSide }?: SideOptions): string;
|
|
21
|
+
export declare function getWebPort({ isPublicSide }?: SideOptions): number;
|
|
22
|
+
export {};
|
|
6
23
|
//# sourceMappingURL=cliHelpers.d.ts.map
|
package/dist/cliHelpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cliHelpers.d.ts","sourceRoot":"","sources":["../src/cliHelpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"cliHelpers.d.ts","sourceRoot":"","sources":["../src/cliHelpers.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACnB;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,UAAU,CAAC,EAAE,YAAoB,EAAE,GAAE,WAAgB,UAYpE;AAED,wBAAgB,UAAU,CAAC,EAAE,YAAoB,EAAE,GAAE,WAAgB,UAcpE;AAED,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,UAAU,CAAC,EAAE,YAAoB,EAAE,GAAE,WAAgB,UAYpE;AAED,wBAAgB,UAAU,CAAC,EAAE,YAAoB,EAAE,GAAE,WAAgB,UAcpE"}
|
package/dist/cliHelpers.js
CHANGED
|
@@ -1,24 +1,52 @@
|
|
|
1
|
-
import { getConfig } from "@cedarjs/project-config";
|
|
2
|
-
function getAPIHost() {
|
|
3
|
-
let host =
|
|
1
|
+
import { getConfig, parsePort, readEnvVar } from "@cedarjs/project-config";
|
|
2
|
+
function getAPIHost({ isPublicSide = false } = {}) {
|
|
3
|
+
let host = readEnvVar("CEDAR_API_HOST", {
|
|
4
|
+
deprecatedAlias: "REDWOOD_API_HOST"
|
|
5
|
+
});
|
|
6
|
+
if (isPublicSide) {
|
|
7
|
+
host ??= process.env.HOST;
|
|
8
|
+
}
|
|
4
9
|
host ??= getConfig().api.host;
|
|
5
10
|
host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
|
|
6
11
|
return host;
|
|
7
12
|
}
|
|
8
|
-
function getAPIPort() {
|
|
9
|
-
|
|
13
|
+
function getAPIPort({ isPublicSide = false } = {}) {
|
|
14
|
+
const apiPort = readEnvVar("CEDAR_API_PORT", {
|
|
15
|
+
deprecatedAlias: "REDWOOD_API_PORT"
|
|
16
|
+
});
|
|
17
|
+
if (apiPort) {
|
|
18
|
+
return parsePort(apiPort, "CEDAR_API_PORT");
|
|
19
|
+
}
|
|
20
|
+
if (isPublicSide && process.env.PORT) {
|
|
21
|
+
return parsePort(process.env.PORT, "PORT");
|
|
22
|
+
}
|
|
23
|
+
return getConfig().api.port;
|
|
10
24
|
}
|
|
11
25
|
function getAPIRootPath() {
|
|
12
26
|
return process.env.CEDAR_API_ROOT_PATH ?? "/";
|
|
13
27
|
}
|
|
14
|
-
function getWebHost() {
|
|
15
|
-
let host =
|
|
28
|
+
function getWebHost({ isPublicSide = false } = {}) {
|
|
29
|
+
let host = readEnvVar("CEDAR_WEB_HOST", {
|
|
30
|
+
deprecatedAlias: "REDWOOD_WEB_HOST"
|
|
31
|
+
});
|
|
32
|
+
if (isPublicSide) {
|
|
33
|
+
host ??= process.env.HOST;
|
|
34
|
+
}
|
|
16
35
|
host ??= getConfig().web.host;
|
|
17
36
|
host ??= process.env.NODE_ENV === "production" ? "0.0.0.0" : "::";
|
|
18
37
|
return host;
|
|
19
38
|
}
|
|
20
|
-
function getWebPort() {
|
|
21
|
-
|
|
39
|
+
function getWebPort({ isPublicSide = false } = {}) {
|
|
40
|
+
const webPort = readEnvVar("CEDAR_WEB_PORT", {
|
|
41
|
+
deprecatedAlias: "REDWOOD_WEB_PORT"
|
|
42
|
+
});
|
|
43
|
+
if (webPort) {
|
|
44
|
+
return parsePort(webPort, "CEDAR_WEB_PORT");
|
|
45
|
+
}
|
|
46
|
+
if (isPublicSide && process.env.PORT) {
|
|
47
|
+
return parsePort(process.env.PORT, "PORT");
|
|
48
|
+
}
|
|
49
|
+
return getConfig().web.port;
|
|
22
50
|
}
|
|
23
51
|
export {
|
|
24
52
|
getAPIHost,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/api-server",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2819",
|
|
4
4
|
"description": "CedarJS's HTTP server for Serverless Functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"test:watch": "vitest watch"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@cedarjs/api": "6.0.0-canary.
|
|
104
|
-
"@cedarjs/context": "6.0.0-canary.
|
|
105
|
-
"@cedarjs/fastify-web": "6.0.0-canary.
|
|
106
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
107
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
108
|
-
"@cedarjs/web-server": "6.0.0-canary.
|
|
103
|
+
"@cedarjs/api": "6.0.0-canary.2819",
|
|
104
|
+
"@cedarjs/context": "6.0.0-canary.2819",
|
|
105
|
+
"@cedarjs/fastify-web": "6.0.0-canary.2819",
|
|
106
|
+
"@cedarjs/internal": "6.0.0-canary.2819",
|
|
107
|
+
"@cedarjs/project-config": "6.0.0-canary.2819",
|
|
108
|
+
"@cedarjs/web-server": "6.0.0-canary.2819",
|
|
109
109
|
"@fastify/multipart": "9.4.0",
|
|
110
110
|
"@fastify/url-data": "6.0.3",
|
|
111
111
|
"ansis": "4.3.1",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"yargs": "17.7.3"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
126
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2819",
|
|
127
127
|
"@types/aws-lambda": "8.10.162",
|
|
128
128
|
"@types/dotenv-defaults": "^5.0.0",
|
|
129
129
|
"@types/split2": "4.2.3",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"vitest": "4.1.10"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
141
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2819"
|
|
142
142
|
},
|
|
143
143
|
"peerDependenciesMeta": {
|
|
144
144
|
"@cedarjs/graphql-server": {
|