@redmix/api-server 9.0.0-canary.625 → 9.0.0-canary.627
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"apiCLIConfigHandler.d.ts","sourceRoot":"","sources":["../src/apiCLIConfigHandler.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"apiCLIConfigHandler.d.ts","sourceRoot":"","sources":["../src/apiCLIConfigHandler.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAsB,OAAO,CAAC,OAAO,GAAE,gBAAqB,iBAoC3D"}
|
@@ -33,17 +33,16 @@ __export(apiCLIConfigHandler_exports, {
|
|
33
33
|
module.exports = __toCommonJS(apiCLIConfigHandler_exports);
|
34
34
|
var import_chalk = __toESM(require("chalk"));
|
35
35
|
var import_fastify_web = require("@redmix/fastify-web");
|
36
|
-
var import_cliHelpers = require("./cliHelpers");
|
37
36
|
var import_createServer = require("./createServer");
|
38
37
|
async function handler(options = {}) {
|
39
38
|
const timeStart = Date.now();
|
40
39
|
console.log(import_chalk.default.dim.italic("Starting API Server..."));
|
41
40
|
options.apiRootPath = (0, import_fastify_web.coerceRootPath)(options.apiRootPath ?? "/");
|
42
41
|
const fastify = await (0, import_createServer.createServer)({
|
43
|
-
apiRootPath: options.apiRootPath
|
42
|
+
apiRootPath: options.apiRootPath,
|
43
|
+
apiHost: options.host,
|
44
|
+
apiPort: options.port
|
44
45
|
});
|
45
|
-
options.host ??= (0, import_cliHelpers.getAPIHost)();
|
46
|
-
options.port ??= (0, import_cliHelpers.getAPIPort)();
|
47
46
|
await fastify.start();
|
48
47
|
fastify.log.trace(
|
49
48
|
{ custom: { ...fastify.initialConfig } },
|
package/dist/bin.js
CHANGED
@@ -60,19 +60,20 @@ var init_cliHelpers = __esm({
|
|
60
60
|
// src/createServerHelpers.ts
|
61
61
|
function resolveOptions(options = {}, args) {
|
62
62
|
options.parseArgs ??= true;
|
63
|
-
|
63
|
+
const defaults = getDefaultCreateServerOptions();
|
64
|
+
options.logger ??= defaults.logger;
|
64
65
|
const resolvedOptions = {
|
65
|
-
apiRootPath: options.apiRootPath ??
|
66
|
+
apiRootPath: options.apiRootPath ?? defaults.apiRootPath,
|
66
67
|
fastifyServerOptions: options.fastifyServerOptions ?? {
|
67
|
-
requestTimeout:
|
68
|
-
logger: options.logger ??
|
69
|
-
bodyLimit:
|
68
|
+
requestTimeout: defaults.fastifyServerOptions.requestTimeout,
|
69
|
+
logger: options.logger ?? defaults.logger,
|
70
|
+
bodyLimit: defaults.fastifyServerOptions.bodyLimit
|
70
71
|
},
|
71
|
-
configureApiServer: options.configureApiServer ??
|
72
|
-
apiHost:
|
73
|
-
apiPort:
|
72
|
+
configureApiServer: options.configureApiServer ?? defaults.configureApiServer,
|
73
|
+
apiHost: options.apiHost ?? defaults.apiHost,
|
74
|
+
apiPort: options.apiPort ?? defaults.apiPort
|
74
75
|
};
|
75
|
-
resolvedOptions.fastifyServerOptions.requestTimeout ??=
|
76
|
+
resolvedOptions.fastifyServerOptions.requestTimeout ??= defaults.fastifyServerOptions.requestTimeout;
|
76
77
|
resolvedOptions.fastifyServerOptions.logger = options.logger;
|
77
78
|
if (options.parseArgs) {
|
78
79
|
const { values } = (0, import_util.parseArgs)({
|
@@ -113,14 +114,14 @@ function resolveOptions(options = {}, args) {
|
|
113
114
|
resolvedOptions.apiRootPath = (0, import_helpers.coerceRootPath)(resolvedOptions.apiRootPath);
|
114
115
|
return resolvedOptions;
|
115
116
|
}
|
116
|
-
var import_util, import_helpers,
|
117
|
+
var import_util, import_helpers, getDefaultCreateServerOptions;
|
117
118
|
var init_createServerHelpers = __esm({
|
118
119
|
"src/createServerHelpers.ts"() {
|
119
120
|
"use strict";
|
120
121
|
import_util = require("util");
|
121
122
|
import_helpers = require("@redmix/fastify-web/dist/helpers");
|
122
123
|
init_cliHelpers();
|
123
|
-
|
124
|
+
getDefaultCreateServerOptions = () => ({
|
124
125
|
apiRootPath: "/",
|
125
126
|
logger: {
|
126
127
|
level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === "development" ? "debug" : "warn")
|
@@ -132,8 +133,10 @@ var init_createServerHelpers = __esm({
|
|
132
133
|
},
|
133
134
|
configureApiServer: () => {
|
134
135
|
},
|
135
|
-
parseArgs: true
|
136
|
-
|
136
|
+
parseArgs: true,
|
137
|
+
apiHost: getAPIHost(),
|
138
|
+
apiPort: getAPIPort()
|
139
|
+
});
|
137
140
|
}
|
138
141
|
});
|
139
142
|
|
@@ -639,10 +642,10 @@ async function handler(options = {}) {
|
|
639
642
|
console.log(import_chalk3.default.dim.italic("Starting API Server..."));
|
640
643
|
options.apiRootPath = (0, import_fastify_web.coerceRootPath)(options.apiRootPath ?? "/");
|
641
644
|
const fastify2 = await createServer({
|
642
|
-
apiRootPath: options.apiRootPath
|
645
|
+
apiRootPath: options.apiRootPath,
|
646
|
+
apiHost: options.host,
|
647
|
+
apiPort: options.port
|
643
648
|
});
|
644
|
-
options.host ??= getAPIHost();
|
645
|
-
options.port ??= getAPIPort();
|
646
649
|
await fastify2.start();
|
647
650
|
fastify2.log.trace(
|
648
651
|
{ custom: { ...fastify2.initialConfig } },
|
@@ -667,7 +670,6 @@ var init_apiCLIConfigHandler = __esm({
|
|
667
670
|
"use strict";
|
668
671
|
import_chalk3 = __toESM(require("chalk"));
|
669
672
|
import_fastify_web = require("@redmix/fastify-web");
|
670
|
-
init_cliHelpers();
|
671
673
|
init_createServer();
|
672
674
|
}
|
673
675
|
});
|
@@ -17,15 +17,17 @@ export interface CreateServerOptions {
|
|
17
17
|
configureApiServer?: (server: Server) => void | Promise<void>;
|
18
18
|
/** Whether to parse args or not. Defaults to `true` */
|
19
19
|
parseArgs?: boolean;
|
20
|
+
/** The port to listen on. Defaults to what's configured in redwood.toml */
|
21
|
+
apiPort?: number;
|
22
|
+
/** The host to bind to. Defaults to what's configured in redwood.toml */
|
23
|
+
apiHost?: string;
|
20
24
|
}
|
21
25
|
type DefaultCreateServerOptions = Required<Omit<CreateServerOptions, 'fastifyServerOptions'> & {
|
22
26
|
fastifyServerOptions: FastifyServerOptions;
|
23
27
|
}>;
|
24
|
-
export declare const
|
28
|
+
export declare const getDefaultCreateServerOptions: () => DefaultCreateServerOptions;
|
25
29
|
export declare function resolveOptions(options?: CreateServerOptions, args?: string[]): Required<Omit<CreateServerOptions, "logger" | "fastifyServerOptions" | "parseArgs"> & {
|
26
30
|
fastifyServerOptions: FastifyServerOptions;
|
27
|
-
apiPort: number;
|
28
|
-
apiHost: string;
|
29
31
|
}>;
|
30
32
|
export {};
|
31
33
|
//# sourceMappingURL=createServerHelpers.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createServerHelpers.d.ts","sourceRoot":"","sources":["../src/createServerHelpers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAChB,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;AAEtE,MAAM,WAAW,MAAO,SAAQ,eAAe;IAC7C,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CACnD;AAED,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,iCAAiC;IACjC,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IAEvC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAA;IAE3D,sEAAsE;IACtE,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7D,uDAAuD;IAC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
|
@@ -18,14 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
19
|
var createServerHelpers_exports = {};
|
20
20
|
__export(createServerHelpers_exports, {
|
21
|
-
|
21
|
+
getDefaultCreateServerOptions: () => getDefaultCreateServerOptions,
|
22
22
|
resolveOptions: () => resolveOptions
|
23
23
|
});
|
24
24
|
module.exports = __toCommonJS(createServerHelpers_exports);
|
25
25
|
var import_util = require("util");
|
26
26
|
var import_helpers = require("@redmix/fastify-web/dist/helpers");
|
27
27
|
var import_cliHelpers = require("./cliHelpers");
|
28
|
-
const
|
28
|
+
const getDefaultCreateServerOptions = () => ({
|
29
29
|
apiRootPath: "/",
|
30
30
|
logger: {
|
31
31
|
level: process.env.LOG_LEVEL ?? (process.env.NODE_ENV === "development" ? "debug" : "warn")
|
@@ -37,23 +37,26 @@ const DEFAULT_CREATE_SERVER_OPTIONS = {
|
|
37
37
|
},
|
38
38
|
configureApiServer: () => {
|
39
39
|
},
|
40
|
-
parseArgs: true
|
41
|
-
|
40
|
+
parseArgs: true,
|
41
|
+
apiHost: (0, import_cliHelpers.getAPIHost)(),
|
42
|
+
apiPort: (0, import_cliHelpers.getAPIPort)()
|
43
|
+
});
|
42
44
|
function resolveOptions(options = {}, args) {
|
43
45
|
options.parseArgs ??= true;
|
44
|
-
|
46
|
+
const defaults = getDefaultCreateServerOptions();
|
47
|
+
options.logger ??= defaults.logger;
|
45
48
|
const resolvedOptions = {
|
46
|
-
apiRootPath: options.apiRootPath ??
|
49
|
+
apiRootPath: options.apiRootPath ?? defaults.apiRootPath,
|
47
50
|
fastifyServerOptions: options.fastifyServerOptions ?? {
|
48
|
-
requestTimeout:
|
49
|
-
logger: options.logger ??
|
50
|
-
bodyLimit:
|
51
|
+
requestTimeout: defaults.fastifyServerOptions.requestTimeout,
|
52
|
+
logger: options.logger ?? defaults.logger,
|
53
|
+
bodyLimit: defaults.fastifyServerOptions.bodyLimit
|
51
54
|
},
|
52
|
-
configureApiServer: options.configureApiServer ??
|
53
|
-
apiHost:
|
54
|
-
apiPort:
|
55
|
+
configureApiServer: options.configureApiServer ?? defaults.configureApiServer,
|
56
|
+
apiHost: options.apiHost ?? defaults.apiHost,
|
57
|
+
apiPort: options.apiPort ?? defaults.apiPort
|
55
58
|
};
|
56
|
-
resolvedOptions.fastifyServerOptions.requestTimeout ??=
|
59
|
+
resolvedOptions.fastifyServerOptions.requestTimeout ??= defaults.fastifyServerOptions.requestTimeout;
|
57
60
|
resolvedOptions.fastifyServerOptions.logger = options.logger;
|
58
61
|
if (options.parseArgs) {
|
59
62
|
const { values } = (0, import_util.parseArgs)({
|
@@ -96,6 +99,6 @@ function resolveOptions(options = {}, args) {
|
|
96
99
|
}
|
97
100
|
// Annotate the CommonJS export names for ESM import in node:
|
98
101
|
0 && (module.exports = {
|
99
|
-
|
102
|
+
getDefaultCreateServerOptions,
|
100
103
|
resolveOptions
|
101
104
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@redmix/api-server",
|
3
|
-
"version": "9.0.0-canary.
|
3
|
+
"version": "9.0.0-canary.627+da923d67a",
|
4
4
|
"description": "Redwood's HTTP server for Serverless Functions",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -31,11 +31,11 @@
|
|
31
31
|
"dependencies": {
|
32
32
|
"@fastify/multipart": "8.3.1",
|
33
33
|
"@fastify/url-data": "5.4.0",
|
34
|
-
"@redmix/context": "9.0.0-canary.
|
35
|
-
"@redmix/fastify-web": "9.0.0-canary.
|
36
|
-
"@redmix/internal": "9.0.0-canary.
|
37
|
-
"@redmix/project-config": "9.0.0-canary.
|
38
|
-
"@redmix/web-server": "9.0.0-canary.
|
34
|
+
"@redmix/context": "9.0.0-canary.627",
|
35
|
+
"@redmix/fastify-web": "9.0.0-canary.627",
|
36
|
+
"@redmix/internal": "9.0.0-canary.627",
|
37
|
+
"@redmix/project-config": "9.0.0-canary.627",
|
38
|
+
"@redmix/web-server": "9.0.0-canary.627",
|
39
39
|
"chalk": "4.1.2",
|
40
40
|
"chokidar": "3.6.0",
|
41
41
|
"dotenv-defaults": "5.0.2",
|
@@ -51,7 +51,7 @@
|
|
51
51
|
"yargs": "17.7.2"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
|
-
"@redmix/framework-tools": "9.0.0-canary.
|
54
|
+
"@redmix/framework-tools": "9.0.0-canary.627",
|
55
55
|
"@types/aws-lambda": "8.10.145",
|
56
56
|
"@types/lodash": "4.17.15",
|
57
57
|
"@types/qs": "6.9.16",
|
@@ -63,12 +63,12 @@
|
|
63
63
|
"vitest": "2.1.9"
|
64
64
|
},
|
65
65
|
"peerDependencies": {
|
66
|
-
"@redmix/graphql-server": "9.0.0-canary.
|
66
|
+
"@redmix/graphql-server": "9.0.0-canary.627"
|
67
67
|
},
|
68
68
|
"peerDependenciesMeta": {
|
69
69
|
"@redmix/graphql-server": {
|
70
70
|
"optional": true
|
71
71
|
}
|
72
72
|
},
|
73
|
-
"gitHead": "
|
73
|
+
"gitHead": "da923d67aea3c0e3546d988d90db2c084fbcec45"
|
74
74
|
}
|