@redmix/api-server 9.0.0-canary.624 → 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":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,wBAAsB,OAAO,CAAC,OAAO,GAAE,gBAAqB,iBAqC3D"}
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
- options.logger ??= DEFAULT_CREATE_SERVER_OPTIONS.logger;
63
+ const defaults = getDefaultCreateServerOptions();
64
+ options.logger ??= defaults.logger;
64
65
  const resolvedOptions = {
65
- apiRootPath: options.apiRootPath ?? DEFAULT_CREATE_SERVER_OPTIONS.apiRootPath,
66
+ apiRootPath: options.apiRootPath ?? defaults.apiRootPath,
66
67
  fastifyServerOptions: options.fastifyServerOptions ?? {
67
- requestTimeout: DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.requestTimeout,
68
- logger: options.logger ?? DEFAULT_CREATE_SERVER_OPTIONS.logger,
69
- bodyLimit: DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.bodyLimit
68
+ requestTimeout: defaults.fastifyServerOptions.requestTimeout,
69
+ logger: options.logger ?? defaults.logger,
70
+ bodyLimit: defaults.fastifyServerOptions.bodyLimit
70
71
  },
71
- configureApiServer: options.configureApiServer ?? DEFAULT_CREATE_SERVER_OPTIONS.configureApiServer,
72
- apiHost: getAPIHost(),
73
- apiPort: getAPIPort()
72
+ configureApiServer: options.configureApiServer ?? defaults.configureApiServer,
73
+ apiHost: options.apiHost ?? defaults.apiHost,
74
+ apiPort: options.apiPort ?? defaults.apiPort
74
75
  };
75
- resolvedOptions.fastifyServerOptions.requestTimeout ??= DEFAULT_CREATE_SERVER_OPTIONS.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, DEFAULT_CREATE_SERVER_OPTIONS;
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
- DEFAULT_CREATE_SERVER_OPTIONS = {
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
  });
@@ -4,36 +4,30 @@ export interface Server extends FastifyInstance {
4
4
  start: (options?: StartOptions) => Promise<string>;
5
5
  }
6
6
  export interface CreateServerOptions {
7
- /**
8
- * The prefix for all routes. Defaults to `/`.
9
- */
7
+ /** The prefix for all routes. Defaults to `/` */
10
8
  apiRootPath?: string;
11
- /**
12
- * Logger instance or options.
13
- */
9
+ /** Logger instance or options */
14
10
  logger?: FastifyServerOptions['logger'];
15
11
  /**
16
12
  * Options for the fastify server instance.
17
13
  * Omitting logger here because we move it up.
18
14
  */
19
15
  fastifyServerOptions?: Omit<FastifyServerOptions, 'logger'>;
20
- /**
21
- * Customise the API server fastify plugin before it is registered
22
- */
16
+ /** Customise the API server fastify plugin before it is registered */
23
17
  configureApiServer?: (server: Server) => void | Promise<void>;
24
- /**
25
- * Whether to parse args or not. Defaults to `true`.
26
- */
18
+ /** Whether to parse args or not. Defaults to `true` */
27
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;
28
24
  }
29
25
  type DefaultCreateServerOptions = Required<Omit<CreateServerOptions, 'fastifyServerOptions'> & {
30
26
  fastifyServerOptions: FastifyServerOptions;
31
27
  }>;
32
- export declare const DEFAULT_CREATE_SERVER_OPTIONS: DefaultCreateServerOptions;
28
+ export declare const getDefaultCreateServerOptions: () => DefaultCreateServerOptions;
33
29
  export declare function resolveOptions(options?: CreateServerOptions, args?: string[]): Required<Omit<CreateServerOptions, "logger" | "fastifyServerOptions" | "parseArgs"> & {
34
30
  fastifyServerOptions: FastifyServerOptions;
35
- apiPort: number;
36
- apiHost: string;
37
31
  }>;
38
32
  export {};
39
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,EAA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iC;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;IACvD,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,KAAK,0BAA0B,GAAG,QAAQ,CACxC,IAAI,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG;IAClD,oBAAoB,EAAE,oBAAoB,CAAA;CAC3C,CACF,CAAA;AAID,eAAO,MAAM,6BAA6B,EAAE,MAAM,0BAgB9C,CAAA;AAQJ,wBAAgB,cAAc,CAC5B,OAAO,GAAE,mBAAwB,EACjC,IAAI,CAAC,EAAE,MAAM,EAAE;0BANS,oBAAoB;GA8E7C"}
@@ -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
- DEFAULT_CREATE_SERVER_OPTIONS: () => DEFAULT_CREATE_SERVER_OPTIONS,
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 DEFAULT_CREATE_SERVER_OPTIONS = {
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
- options.logger ??= DEFAULT_CREATE_SERVER_OPTIONS.logger;
46
+ const defaults = getDefaultCreateServerOptions();
47
+ options.logger ??= defaults.logger;
45
48
  const resolvedOptions = {
46
- apiRootPath: options.apiRootPath ?? DEFAULT_CREATE_SERVER_OPTIONS.apiRootPath,
49
+ apiRootPath: options.apiRootPath ?? defaults.apiRootPath,
47
50
  fastifyServerOptions: options.fastifyServerOptions ?? {
48
- requestTimeout: DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.requestTimeout,
49
- logger: options.logger ?? DEFAULT_CREATE_SERVER_OPTIONS.logger,
50
- bodyLimit: DEFAULT_CREATE_SERVER_OPTIONS.fastifyServerOptions.bodyLimit
51
+ requestTimeout: defaults.fastifyServerOptions.requestTimeout,
52
+ logger: options.logger ?? defaults.logger,
53
+ bodyLimit: defaults.fastifyServerOptions.bodyLimit
51
54
  },
52
- configureApiServer: options.configureApiServer ?? DEFAULT_CREATE_SERVER_OPTIONS.configureApiServer,
53
- apiHost: (0, import_cliHelpers.getAPIHost)(),
54
- apiPort: (0, import_cliHelpers.getAPIPort)()
55
+ configureApiServer: options.configureApiServer ?? defaults.configureApiServer,
56
+ apiHost: options.apiHost ?? defaults.apiHost,
57
+ apiPort: options.apiPort ?? defaults.apiPort
55
58
  };
56
- resolvedOptions.fastifyServerOptions.requestTimeout ??= DEFAULT_CREATE_SERVER_OPTIONS.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
- DEFAULT_CREATE_SERVER_OPTIONS,
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.624+33697ee95",
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.624",
35
- "@redmix/fastify-web": "9.0.0-canary.624",
36
- "@redmix/internal": "9.0.0-canary.624",
37
- "@redmix/project-config": "9.0.0-canary.624",
38
- "@redmix/web-server": "9.0.0-canary.624",
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.624",
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.624"
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": "33697ee95783d054983eb7599b4a6eeabef73a94"
73
+ "gitHead": "da923d67aea3c0e3546d988d90db2c084fbcec45"
74
74
  }