@cedarjs/api-server 2.8.0 → 2.8.1-next.109

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
@@ -219,18 +219,26 @@ var init_utils = __esm({
219
219
  });
220
220
 
221
221
  // src/requestHandlers/awsLambdaFastify.ts
222
- import qs from "qs";
222
+ import { parse } from "picoquery";
223
223
  var lambdaEventForFastifyRequest, fastifyResponseForLambdaResult, fastifyResponseForLambdaError, requestHandler;
224
224
  var init_awsLambdaFastify = __esm({
225
225
  "src/requestHandlers/awsLambdaFastify.ts"() {
226
226
  "use strict";
227
227
  init_utils();
228
228
  lambdaEventForFastifyRequest = (request) => {
229
+ const qsParams = parse(
230
+ request.url.split(/\?(.+)/)[1],
231
+ {
232
+ nestingSyntax: "index",
233
+ arrayRepeat: true,
234
+ arrayRepeatSyntax: "bracket"
235
+ }
236
+ );
229
237
  return {
230
238
  httpMethod: request.method,
231
239
  headers: request.headers,
232
240
  path: request.urlData("path"),
233
- queryStringParameters: qs.parse(request.url.split(/\?(.+)/)[1]),
241
+ queryStringParameters: qsParams,
234
242
  requestContext: {
235
243
  requestId: request.id,
236
244
  identity: {
@@ -411,12 +419,12 @@ import fastifyUrlData from "@fastify/url-data";
411
419
  import fastifyRawBody from "fastify-raw-body";
412
420
  import { getAsyncStoreInstance as getAsyncStoreInstance2 } from "@cedarjs/context/dist/store";
413
421
  import { coerceRootPath as coerceRootPath2 } from "@cedarjs/fastify-web/dist/helpers.js";
414
- async function redwoodFastifyAPI(fastify2, opts) {
415
- const redwoodOptions = opts.redwood ?? {};
416
- redwoodOptions.apiRootPath ??= "/";
417
- redwoodOptions.apiRootPath = coerceRootPath2(redwoodOptions.apiRootPath);
418
- redwoodOptions.fastGlobOptions ??= {};
419
- redwoodOptions.loadUserConfig ??= false;
422
+ async function cedarFastifyAPI(fastify2, opts) {
423
+ const cedarOptions = opts.redwood ?? {};
424
+ cedarOptions.apiRootPath ??= "/";
425
+ cedarOptions.apiRootPath = coerceRootPath2(cedarOptions.apiRootPath);
426
+ cedarOptions.fastGlobOptions ??= {};
427
+ cedarOptions.loadUserConfig ??= false;
420
428
  fastify2.register(fastifyUrlData);
421
429
  await fastify2.register(fastifyRawBody);
422
430
  fastify2.addHook("onRequest", (_req, _reply, done) => {
@@ -427,23 +435,23 @@ async function redwoodFastifyAPI(fastify2, opts) {
427
435
  { parseAs: "string" },
428
436
  fastify2.defaultTextParser
429
437
  );
430
- if (redwoodOptions.loadUserConfig) {
438
+ if (cedarOptions.loadUserConfig) {
431
439
  const { configureFastify } = await loadFastifyConfig();
432
440
  if (configureFastify) {
433
441
  await configureFastify(fastify2, {
434
442
  side: "api",
435
- apiRootPath: redwoodOptions.apiRootPath
443
+ apiRootPath: cedarOptions.apiRootPath
436
444
  });
437
445
  }
438
446
  }
439
- if (redwoodOptions.configureServer) {
440
- await redwoodOptions.configureServer(fastify2);
447
+ if (cedarOptions.configureServer) {
448
+ await cedarOptions.configureServer(fastify2);
441
449
  }
442
- fastify2.all(`${redwoodOptions.apiRootPath}:routeName`, lambdaRequestHandler);
443
- fastify2.all(`${redwoodOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
450
+ fastify2.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
451
+ fastify2.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
444
452
  await loadFunctionsFromDist({
445
- fastGlobOptions: redwoodOptions.fastGlobOptions,
446
- discoverFunctionsGlob: redwoodOptions.discoverFunctionsGlob
453
+ fastGlobOptions: cedarOptions.fastGlobOptions,
454
+ discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
447
455
  });
448
456
  }
449
457
  var init_api = __esm({
@@ -596,7 +604,7 @@ async function createServer(options = {}) {
596
604
  server.addHook("onRequest", (_req, _reply, done) => {
597
605
  getAsyncStoreInstance4().run(/* @__PURE__ */ new Map(), done);
598
606
  });
599
- await server.register(redwoodFastifyAPI, {
607
+ await server.register(cedarFastifyAPI, {
600
608
  redwood: {
601
609
  apiRootPath,
602
610
  fastGlobOptions: {
package/dist/cjs/bin.js CHANGED
@@ -241,18 +241,26 @@ var init_utils = __esm({
241
241
  });
242
242
 
243
243
  // src/requestHandlers/awsLambdaFastify.ts
244
- var import_qs, lambdaEventForFastifyRequest, fastifyResponseForLambdaResult, fastifyResponseForLambdaError, requestHandler;
244
+ var import_picoquery, lambdaEventForFastifyRequest, fastifyResponseForLambdaResult, fastifyResponseForLambdaError, requestHandler;
245
245
  var init_awsLambdaFastify = __esm({
246
246
  "src/requestHandlers/awsLambdaFastify.ts"() {
247
247
  "use strict";
248
- import_qs = __toESM(require("qs"), 1);
248
+ import_picoquery = require("picoquery");
249
249
  init_utils();
250
250
  lambdaEventForFastifyRequest = (request) => {
251
+ const qsParams = (0, import_picoquery.parse)(
252
+ request.url.split(/\?(.+)/)[1],
253
+ {
254
+ nestingSyntax: "index",
255
+ arrayRepeat: true,
256
+ arrayRepeatSyntax: "bracket"
257
+ }
258
+ );
251
259
  return {
252
260
  httpMethod: request.method,
253
261
  headers: request.headers,
254
262
  path: request.urlData("path"),
255
- queryStringParameters: import_qs.default.parse(request.url.split(/\?(.+)/)[1]),
263
+ queryStringParameters: qsParams,
256
264
  requestContext: {
257
265
  requestId: request.id,
258
266
  identity: {
@@ -429,12 +437,12 @@ var init_lambdaLoader = __esm({
429
437
  });
430
438
 
431
439
  // src/plugins/api.ts
432
- async function redwoodFastifyAPI(fastify2, opts) {
433
- const redwoodOptions = opts.redwood ?? {};
434
- redwoodOptions.apiRootPath ??= "/";
435
- redwoodOptions.apiRootPath = (0, import_helpers2.coerceRootPath)(redwoodOptions.apiRootPath);
436
- redwoodOptions.fastGlobOptions ??= {};
437
- redwoodOptions.loadUserConfig ??= false;
440
+ async function cedarFastifyAPI(fastify2, opts) {
441
+ const cedarOptions = opts.redwood ?? {};
442
+ cedarOptions.apiRootPath ??= "/";
443
+ cedarOptions.apiRootPath = (0, import_helpers2.coerceRootPath)(cedarOptions.apiRootPath);
444
+ cedarOptions.fastGlobOptions ??= {};
445
+ cedarOptions.loadUserConfig ??= false;
438
446
  fastify2.register(import_url_data.default);
439
447
  await fastify2.register(import_fastify_raw_body.default);
440
448
  fastify2.addHook("onRequest", (_req, _reply, done) => {
@@ -445,23 +453,23 @@ async function redwoodFastifyAPI(fastify2, opts) {
445
453
  { parseAs: "string" },
446
454
  fastify2.defaultTextParser
447
455
  );
448
- if (redwoodOptions.loadUserConfig) {
456
+ if (cedarOptions.loadUserConfig) {
449
457
  const { configureFastify } = await loadFastifyConfig();
450
458
  if (configureFastify) {
451
459
  await configureFastify(fastify2, {
452
460
  side: "api",
453
- apiRootPath: redwoodOptions.apiRootPath
461
+ apiRootPath: cedarOptions.apiRootPath
454
462
  });
455
463
  }
456
464
  }
457
- if (redwoodOptions.configureServer) {
458
- await redwoodOptions.configureServer(fastify2);
465
+ if (cedarOptions.configureServer) {
466
+ await cedarOptions.configureServer(fastify2);
459
467
  }
460
- fastify2.all(`${redwoodOptions.apiRootPath}:routeName`, lambdaRequestHandler);
461
- fastify2.all(`${redwoodOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
468
+ fastify2.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
469
+ fastify2.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
462
470
  await loadFunctionsFromDist({
463
- fastGlobOptions: redwoodOptions.fastGlobOptions,
464
- discoverFunctionsGlob: redwoodOptions.discoverFunctionsGlob
471
+ fastGlobOptions: cedarOptions.fastGlobOptions,
472
+ discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
465
473
  });
466
474
  }
467
475
  var import_url_data, import_fastify_raw_body, import_store2, import_helpers2;
@@ -612,7 +620,7 @@ async function createServer(options = {}) {
612
620
  server.addHook("onRequest", (_req, _reply, done) => {
613
621
  (0, import_store4.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), done);
614
622
  });
615
- await server.register(redwoodFastifyAPI, {
623
+ await server.register(cedarFastifyAPI, {
616
624
  redwood: {
617
625
  apiRootPath,
618
626
  fastGlobOptions: {
@@ -93,7 +93,7 @@ async function createServer(options = {}) {
93
93
  server.addHook("onRequest", (_req, _reply, done) => {
94
94
  (0, import_store.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), done);
95
95
  });
96
- await server.register(import_api.redwoodFastifyAPI, {
96
+ await server.register(import_api.cedarFastifyAPI, {
97
97
  redwood: {
98
98
  apiRootPath,
99
99
  fastGlobOptions: {
@@ -1,7 +1,7 @@
1
1
  import type { Options as FastGlobOptions } from 'fast-glob';
2
2
  import type { FastifyInstance } from 'fastify';
3
3
  import type { Server } from '../createServerHelpers.js';
4
- export interface RedwoodFastifyAPIOptions {
4
+ export interface CedarFastifyAPIOptions {
5
5
  redwood: {
6
6
  apiRootPath?: string;
7
7
  fastGlobOptions?: FastGlobOptions;
@@ -10,5 +10,5 @@ export interface RedwoodFastifyAPIOptions {
10
10
  configureServer?: (server: Server) => void | Promise<void>;
11
11
  };
12
12
  }
13
- export declare function redwoodFastifyAPI(fastify: FastifyInstance, opts: RedwoodFastifyAPIOptions): Promise<void>;
13
+ export declare function cedarFastifyAPI(fastify: FastifyInstance, opts: CedarFastifyAPIOptions): Promise<void>;
14
14
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/plugins/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAKvD,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACzC,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAC3D,CAAA;CACF;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,iBA4C/B"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/plugins/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAKvD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACzC,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAC3D,CAAA;CACF;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,sBAAsB,iBA4C7B"}
@@ -28,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var api_exports = {};
30
30
  __export(api_exports, {
31
- redwoodFastifyAPI: () => redwoodFastifyAPI
31
+ cedarFastifyAPI: () => cedarFastifyAPI
32
32
  });
33
33
  module.exports = __toCommonJS(api_exports);
34
34
  var import_url_data = __toESM(require("@fastify/url-data"), 1);
@@ -37,12 +37,12 @@ var import_store = require("@cedarjs/context/dist/store");
37
37
  var import_helpers = require("@cedarjs/fastify-web/dist/helpers.js");
38
38
  var import_fastify = require("../fastify.js");
39
39
  var import_lambdaLoader = require("./lambdaLoader.js");
40
- async function redwoodFastifyAPI(fastify, opts) {
41
- const redwoodOptions = opts.redwood ?? {};
42
- redwoodOptions.apiRootPath ??= "/";
43
- redwoodOptions.apiRootPath = (0, import_helpers.coerceRootPath)(redwoodOptions.apiRootPath);
44
- redwoodOptions.fastGlobOptions ??= {};
45
- redwoodOptions.loadUserConfig ??= false;
40
+ async function cedarFastifyAPI(fastify, opts) {
41
+ const cedarOptions = opts.redwood ?? {};
42
+ cedarOptions.apiRootPath ??= "/";
43
+ cedarOptions.apiRootPath = (0, import_helpers.coerceRootPath)(cedarOptions.apiRootPath);
44
+ cedarOptions.fastGlobOptions ??= {};
45
+ cedarOptions.loadUserConfig ??= false;
46
46
  fastify.register(import_url_data.default);
47
47
  await fastify.register(import_fastify_raw_body.default);
48
48
  fastify.addHook("onRequest", (_req, _reply, done) => {
@@ -53,26 +53,26 @@ async function redwoodFastifyAPI(fastify, opts) {
53
53
  { parseAs: "string" },
54
54
  fastify.defaultTextParser
55
55
  );
56
- if (redwoodOptions.loadUserConfig) {
56
+ if (cedarOptions.loadUserConfig) {
57
57
  const { configureFastify } = await (0, import_fastify.loadFastifyConfig)();
58
58
  if (configureFastify) {
59
59
  await configureFastify(fastify, {
60
60
  side: "api",
61
- apiRootPath: redwoodOptions.apiRootPath
61
+ apiRootPath: cedarOptions.apiRootPath
62
62
  });
63
63
  }
64
64
  }
65
- if (redwoodOptions.configureServer) {
66
- await redwoodOptions.configureServer(fastify);
65
+ if (cedarOptions.configureServer) {
66
+ await cedarOptions.configureServer(fastify);
67
67
  }
68
- fastify.all(`${redwoodOptions.apiRootPath}:routeName`, import_lambdaLoader.lambdaRequestHandler);
69
- fastify.all(`${redwoodOptions.apiRootPath}:routeName/*`, import_lambdaLoader.lambdaRequestHandler);
68
+ fastify.all(`${cedarOptions.apiRootPath}:routeName`, import_lambdaLoader.lambdaRequestHandler);
69
+ fastify.all(`${cedarOptions.apiRootPath}:routeName/*`, import_lambdaLoader.lambdaRequestHandler);
70
70
  await (0, import_lambdaLoader.loadFunctionsFromDist)({
71
- fastGlobOptions: redwoodOptions.fastGlobOptions,
72
- discoverFunctionsGlob: redwoodOptions.discoverFunctionsGlob
71
+ fastGlobOptions: cedarOptions.fastGlobOptions,
72
+ discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
73
73
  });
74
74
  }
75
75
  // Annotate the CommonJS export names for ESM import in node:
76
76
  0 && (module.exports = {
77
- redwoodFastifyAPI
77
+ cedarFastifyAPI
78
78
  });
@@ -1 +1 @@
1
- {"version":3,"file":"awsLambdaFastify.d.ts","sourceRoot":"","sources":["../../../src/requestHandlers/awsLambdaFastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,OAAO,EACR,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAK3D,eAAO,MAAM,4BAA4B,GACvC,SAAS,cAAc,KACtB,oBAcF,CAAA;AAoCD,eAAO,MAAM,cAAc,GACzB,KAAK,cAAc,EACnB,OAAO,YAAY,EACnB,SAAS,OAAO,kBAmCjB,CAAA"}
1
+ {"version":3,"file":"awsLambdaFastify.d.ts","sourceRoot":"","sources":["../../../src/requestHandlers/awsLambdaFastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,OAAO,EAER,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAK3D,eAAO,MAAM,4BAA4B,GACvC,SAAS,cAAc,KACtB,oBAyBF,CAAA;AAoCD,eAAO,MAAM,cAAc,GACzB,KAAK,cAAc,EACnB,OAAO,YAAY,EACnB,SAAS,OAAO,kBAmCjB,CAAA"}
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var awsLambdaFastify_exports = {};
30
20
  __export(awsLambdaFastify_exports, {
@@ -32,14 +22,22 @@ __export(awsLambdaFastify_exports, {
32
22
  requestHandler: () => requestHandler
33
23
  });
34
24
  module.exports = __toCommonJS(awsLambdaFastify_exports);
35
- var import_qs = __toESM(require("qs"), 1);
25
+ var import_picoquery = require("picoquery");
36
26
  var import_utils = require("./utils.js");
37
27
  const lambdaEventForFastifyRequest = (request) => {
28
+ const qsParams = (0, import_picoquery.parse)(
29
+ request.url.split(/\?(.+)/)[1],
30
+ {
31
+ nestingSyntax: "index",
32
+ arrayRepeat: true,
33
+ arrayRepeatSyntax: "bracket"
34
+ }
35
+ );
38
36
  return {
39
37
  httpMethod: request.method,
40
38
  headers: request.headers,
41
39
  path: request.urlData("path"),
42
- queryStringParameters: import_qs.default.parse(request.url.split(/\?(.+)/)[1]),
40
+ queryStringParameters: qsParams,
43
41
  requestContext: {
44
42
  requestId: request.id,
45
43
  identity: {
@@ -1,19 +1,19 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { RedwoodFastifyAPIOptions } from './plugins/api.js';
2
+ import type { CedarFastifyAPIOptions } from './plugins/api.js';
3
3
  export type FastifySideConfigFnOptions = {
4
4
  side: 'api' | 'web';
5
5
  };
6
- export type FastifySideConfigFn = (fastify: FastifyInstance, options?: FastifySideConfigFnOptions & Pick<RedwoodFastifyAPIOptions['redwood'], 'apiRootPath'>) => Promise<FastifyInstance> | void;
6
+ export type FastifySideConfigFn = (fastify: FastifyInstance, options?: FastifySideConfigFnOptions & Pick<CedarFastifyAPIOptions['redwood'], 'apiRootPath'>) => Promise<FastifyInstance> | void;
7
7
  export type APIParsedOptions = {
8
8
  port?: number;
9
9
  host?: string;
10
10
  loadEnvFiles?: boolean;
11
- } & Omit<RedwoodFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
11
+ } & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
12
12
  export type BothParsedOptions = {
13
13
  webPort?: number;
14
14
  webHost?: string;
15
15
  apiPort?: number;
16
16
  apiHost?: string;
17
17
  apiRootPath?: string;
18
- } & Omit<RedwoodFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
18
+ } & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
19
19
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAGhE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,0BAA0B,GAClC,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,KACvD,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAG9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,0BAA0B,GAClC,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,KACrD,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAE9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA"}
@@ -7,7 +7,7 @@ import fastify from "fastify";
7
7
  import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
8
8
  import { getConfig, getPaths } from "@cedarjs/project-config";
9
9
  import { resolveOptions } from "./createServerHelpers.js";
10
- import { redwoodFastifyAPI } from "./plugins/api.js";
10
+ import { cedarFastifyAPI } from "./plugins/api.js";
11
11
  if (!process.env.REDWOOD_ENV_FILES_LOADED) {
12
12
  config({
13
13
  path: path.join(getPaths().base, ".env"),
@@ -60,7 +60,7 @@ async function createServer(options = {}) {
60
60
  server.addHook("onRequest", (_req, _reply, done) => {
61
61
  getAsyncStoreInstance().run(/* @__PURE__ */ new Map(), done);
62
62
  });
63
- await server.register(redwoodFastifyAPI, {
63
+ await server.register(cedarFastifyAPI, {
64
64
  redwood: {
65
65
  apiRootPath,
66
66
  fastGlobOptions: {
@@ -1,7 +1,7 @@
1
1
  import type { Options as FastGlobOptions } from 'fast-glob';
2
2
  import type { FastifyInstance } from 'fastify';
3
3
  import type { Server } from '../createServerHelpers.js';
4
- export interface RedwoodFastifyAPIOptions {
4
+ export interface CedarFastifyAPIOptions {
5
5
  redwood: {
6
6
  apiRootPath?: string;
7
7
  fastGlobOptions?: FastGlobOptions;
@@ -10,5 +10,5 @@ export interface RedwoodFastifyAPIOptions {
10
10
  configureServer?: (server: Server) => void | Promise<void>;
11
11
  };
12
12
  }
13
- export declare function redwoodFastifyAPI(fastify: FastifyInstance, opts: RedwoodFastifyAPIOptions): Promise<void>;
13
+ export declare function cedarFastifyAPI(fastify: FastifyInstance, opts: CedarFastifyAPIOptions): Promise<void>;
14
14
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/plugins/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAKvD,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACzC,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAC3D,CAAA;CACF;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,iBA4C/B"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/plugins/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAO9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAKvD,MAAM,WAAW,sBAAsB;IAErC,OAAO,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,eAAe,CAAA;QACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;QACzC,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;KAC3D,CAAA;CACF;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,sBAAsB,iBA4C7B"}
@@ -4,12 +4,12 @@ import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
4
4
  import { coerceRootPath } from "@cedarjs/fastify-web/dist/helpers.js";
5
5
  import { loadFastifyConfig } from "../fastify.js";
6
6
  import { lambdaRequestHandler, loadFunctionsFromDist } from "./lambdaLoader.js";
7
- async function redwoodFastifyAPI(fastify, opts) {
8
- const redwoodOptions = opts.redwood ?? {};
9
- redwoodOptions.apiRootPath ??= "/";
10
- redwoodOptions.apiRootPath = coerceRootPath(redwoodOptions.apiRootPath);
11
- redwoodOptions.fastGlobOptions ??= {};
12
- redwoodOptions.loadUserConfig ??= false;
7
+ async function cedarFastifyAPI(fastify, opts) {
8
+ const cedarOptions = opts.redwood ?? {};
9
+ cedarOptions.apiRootPath ??= "/";
10
+ cedarOptions.apiRootPath = coerceRootPath(cedarOptions.apiRootPath);
11
+ cedarOptions.fastGlobOptions ??= {};
12
+ cedarOptions.loadUserConfig ??= false;
13
13
  fastify.register(fastifyUrlData);
14
14
  await fastify.register(fastifyRawBody);
15
15
  fastify.addHook("onRequest", (_req, _reply, done) => {
@@ -20,25 +20,25 @@ async function redwoodFastifyAPI(fastify, opts) {
20
20
  { parseAs: "string" },
21
21
  fastify.defaultTextParser
22
22
  );
23
- if (redwoodOptions.loadUserConfig) {
23
+ if (cedarOptions.loadUserConfig) {
24
24
  const { configureFastify } = await loadFastifyConfig();
25
25
  if (configureFastify) {
26
26
  await configureFastify(fastify, {
27
27
  side: "api",
28
- apiRootPath: redwoodOptions.apiRootPath
28
+ apiRootPath: cedarOptions.apiRootPath
29
29
  });
30
30
  }
31
31
  }
32
- if (redwoodOptions.configureServer) {
33
- await redwoodOptions.configureServer(fastify);
32
+ if (cedarOptions.configureServer) {
33
+ await cedarOptions.configureServer(fastify);
34
34
  }
35
- fastify.all(`${redwoodOptions.apiRootPath}:routeName`, lambdaRequestHandler);
36
- fastify.all(`${redwoodOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
35
+ fastify.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
36
+ fastify.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
37
37
  await loadFunctionsFromDist({
38
- fastGlobOptions: redwoodOptions.fastGlobOptions,
39
- discoverFunctionsGlob: redwoodOptions.discoverFunctionsGlob
38
+ fastGlobOptions: cedarOptions.fastGlobOptions,
39
+ discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
40
40
  });
41
41
  }
42
42
  export {
43
- redwoodFastifyAPI
43
+ cedarFastifyAPI
44
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"awsLambdaFastify.d.ts","sourceRoot":"","sources":["../../src/requestHandlers/awsLambdaFastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,OAAO,EACR,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAK3D,eAAO,MAAM,4BAA4B,GACvC,SAAS,cAAc,KACtB,oBAcF,CAAA;AAoCD,eAAO,MAAM,cAAc,GACzB,KAAK,cAAc,EACnB,OAAO,YAAY,EACnB,SAAS,OAAO,kBAmCjB,CAAA"}
1
+ {"version":3,"file":"awsLambdaFastify.d.ts","sourceRoot":"","sources":["../../src/requestHandlers/awsLambdaFastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,oBAAoB,EACpB,OAAO,EAER,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAK3D,eAAO,MAAM,4BAA4B,GACvC,SAAS,cAAc,KACtB,oBAyBF,CAAA;AAoCD,eAAO,MAAM,cAAc,GACzB,KAAK,cAAc,EACnB,OAAO,YAAY,EACnB,SAAS,OAAO,kBAmCjB,CAAA"}
@@ -1,11 +1,19 @@
1
- import qs from "qs";
1
+ import { parse } from "picoquery";
2
2
  import { mergeMultiValueHeaders, parseBody } from "./utils.js";
3
3
  const lambdaEventForFastifyRequest = (request) => {
4
+ const qsParams = parse(
5
+ request.url.split(/\?(.+)/)[1],
6
+ {
7
+ nestingSyntax: "index",
8
+ arrayRepeat: true,
9
+ arrayRepeatSyntax: "bracket"
10
+ }
11
+ );
4
12
  return {
5
13
  httpMethod: request.method,
6
14
  headers: request.headers,
7
15
  path: request.urlData("path"),
8
- queryStringParameters: qs.parse(request.url.split(/\?(.+)/)[1]),
16
+ queryStringParameters: qsParams,
9
17
  requestContext: {
10
18
  requestId: request.id,
11
19
  identity: {
package/dist/types.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import type { FastifyInstance } from 'fastify';
2
- import type { RedwoodFastifyAPIOptions } from './plugins/api.js';
2
+ import type { CedarFastifyAPIOptions } from './plugins/api.js';
3
3
  export type FastifySideConfigFnOptions = {
4
4
  side: 'api' | 'web';
5
5
  };
6
- export type FastifySideConfigFn = (fastify: FastifyInstance, options?: FastifySideConfigFnOptions & Pick<RedwoodFastifyAPIOptions['redwood'], 'apiRootPath'>) => Promise<FastifyInstance> | void;
6
+ export type FastifySideConfigFn = (fastify: FastifyInstance, options?: FastifySideConfigFnOptions & Pick<CedarFastifyAPIOptions['redwood'], 'apiRootPath'>) => Promise<FastifyInstance> | void;
7
7
  export type APIParsedOptions = {
8
8
  port?: number;
9
9
  host?: string;
10
10
  loadEnvFiles?: boolean;
11
- } & Omit<RedwoodFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
11
+ } & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
12
12
  export type BothParsedOptions = {
13
13
  webPort?: number;
14
14
  webHost?: string;
15
15
  apiPort?: number;
16
16
  apiHost?: string;
17
17
  apiRootPath?: string;
18
- } & Omit<RedwoodFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
18
+ } & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
19
19
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAGhE,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,0BAA0B,GAClC,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,KACvD,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAG9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,CAAC,EAAE,0BAA0B,GAClC,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC,KACrD,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAA;AAEpC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAE9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api-server",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-next.109+be993981d",
4
4
  "description": "CedarJS's HTTP server for Serverless Functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -111,11 +111,11 @@
111
111
  "test:watch": "vitest watch"
112
112
  },
113
113
  "dependencies": {
114
- "@cedarjs/context": "2.8.0",
115
- "@cedarjs/fastify-web": "2.8.0",
116
- "@cedarjs/internal": "2.8.0",
117
- "@cedarjs/project-config": "2.8.0",
118
- "@cedarjs/web-server": "2.8.0",
114
+ "@cedarjs/context": "2.8.1-next.109+be993981d",
115
+ "@cedarjs/fastify-web": "2.8.1-next.109+be993981d",
116
+ "@cedarjs/internal": "2.8.1-next.109+be993981d",
117
+ "@cedarjs/project-config": "2.8.1-next.109+be993981d",
118
+ "@cedarjs/web-server": "2.8.1-next.109+be993981d",
119
119
  "@fastify/multipart": "9.4.0",
120
120
  "@fastify/url-data": "6.0.3",
121
121
  "ansis": "4.2.0",
@@ -123,23 +123,22 @@
123
123
  "dotenv-defaults": "5.0.2",
124
124
  "fast-glob": "3.3.3",
125
125
  "fast-json-parse": "1.0.3",
126
- "fastify": "5.7.4",
126
+ "fastify": "5.8.2",
127
127
  "fastify-raw-body": "5.0.0",
128
+ "picoquery": "2.5.0",
128
129
  "pretty-bytes": "5.6.0",
129
130
  "pretty-ms": "7.0.1",
130
- "qs": "6.15.0",
131
131
  "split2": "4.2.0",
132
132
  "yargs": "17.7.2"
133
133
  },
134
134
  "devDependencies": {
135
- "@cedarjs/framework-tools": "0.0.0",
135
+ "@cedarjs/framework-tools": "2.8.1-next.109",
136
136
  "@types/aws-lambda": "8.10.161",
137
137
  "@types/dotenv-defaults": "^5.0.0",
138
- "@types/qs": "6.14.0",
139
138
  "@types/split2": "4.2.3",
140
139
  "@types/yargs": "17.0.35",
141
- "graphql-yoga": "5.18.0",
142
- "memfs": "4.56.10",
140
+ "graphql-yoga": "5.18.1",
141
+ "memfs": "4.56.11",
143
142
  "pino-abstract-transport": "1.2.0",
144
143
  "tsx": "4.21.0",
145
144
  "typescript": "5.9.3",
@@ -156,5 +155,5 @@
156
155
  "publishConfig": {
157
156
  "access": "public"
158
157
  },
159
- "gitHead": "0a76e0456b141a96f497b5a900ee6eb811c29004"
158
+ "gitHead": "be993981d7e162a83244009c3f7ab9270c6773f3"
160
159
  }