@cedarjs/api-server 4.0.0-canary.13850 → 4.0.0-canary.13851

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
@@ -336,13 +336,14 @@ var init_lambdaLoader = __esm({
336
336
  "use strict";
337
337
  init_awsLambdaFastify();
338
338
  init_utils2();
339
- LAMBDA_FUNCTIONS = {};
339
+ LAMBDA_FUNCTIONS = /* @__PURE__ */ new Map();
340
340
  CEDAR_HANDLERS = /* @__PURE__ */ new Map();
341
341
  cedarRouteManifest = [];
342
342
  setLambdaFunctions = async (foundFunctions) => {
343
343
  const tsImport = Date.now();
344
344
  console.log(ansis.dim.italic("Importing Server Functions... "));
345
345
  cedarRouteManifest.length = 0;
346
+ LAMBDA_FUNCTIONS.clear();
346
347
  CEDAR_HANDLERS.clear();
347
348
  const imports = foundFunctions.map(async (fnPath) => {
348
349
  const ts = Date.now();
@@ -369,7 +370,7 @@ var init_lambdaLoader = __esm({
369
370
  }
370
371
  return void 0;
371
372
  })();
372
- LAMBDA_FUNCTIONS[routeName] = handler3;
373
+ LAMBDA_FUNCTIONS.set(routeName, handler3);
373
374
  if (cedarHandler) {
374
375
  CEDAR_HANDLERS.set(routeName, cedarHandler);
375
376
  } else if (handler3) {
@@ -453,7 +454,10 @@ var init_lambdaLoader = __esm({
453
454
  reply.send(Buffer.from(body));
454
455
  return;
455
456
  }
456
- if (!LAMBDA_FUNCTIONS[routeName]) {
457
+ const handler3 = LAMBDA_FUNCTIONS.get(routeName);
458
+ if (handler3) {
459
+ return requestHandler(req, reply, handler3);
460
+ } else {
457
461
  const errorMessage = `Function "${routeName}" was not found.`;
458
462
  req.log.error(errorMessage);
459
463
  reply.status(404);
@@ -461,10 +465,7 @@ var init_lambdaLoader = __esm({
461
465
  const devError = {
462
466
  error: errorMessage,
463
467
  availableFunctions: [
464
- .../* @__PURE__ */ new Set([
465
- ...Object.keys(LAMBDA_FUNCTIONS),
466
- ...CEDAR_HANDLERS.keys()
467
- ])
468
+ .../* @__PURE__ */ new Set([...LAMBDA_FUNCTIONS.keys(), ...CEDAR_HANDLERS.keys()])
468
469
  ]
469
470
  };
470
471
  reply.send(devError);
@@ -473,7 +474,6 @@ var init_lambdaLoader = __esm({
473
474
  }
474
475
  return;
475
476
  }
476
- return requestHandler(req, reply, LAMBDA_FUNCTIONS[routeName]);
477
477
  };
478
478
  }
479
479
  });
package/dist/cjs/bin.js CHANGED
@@ -358,13 +358,14 @@ var init_lambdaLoader = __esm({
358
358
  import_project_config3 = require("@cedarjs/project-config");
359
359
  init_awsLambdaFastify();
360
360
  init_utils2();
361
- LAMBDA_FUNCTIONS = {};
361
+ LAMBDA_FUNCTIONS = /* @__PURE__ */ new Map();
362
362
  CEDAR_HANDLERS = /* @__PURE__ */ new Map();
363
363
  cedarRouteManifest = [];
364
364
  setLambdaFunctions = async (foundFunctions) => {
365
365
  const tsImport = Date.now();
366
366
  console.log(import_ansis.default.dim.italic("Importing Server Functions... "));
367
367
  cedarRouteManifest.length = 0;
368
+ LAMBDA_FUNCTIONS.clear();
368
369
  CEDAR_HANDLERS.clear();
369
370
  const imports = foundFunctions.map(async (fnPath) => {
370
371
  const ts = Date.now();
@@ -391,7 +392,7 @@ var init_lambdaLoader = __esm({
391
392
  }
392
393
  return void 0;
393
394
  })();
394
- LAMBDA_FUNCTIONS[routeName] = handler3;
395
+ LAMBDA_FUNCTIONS.set(routeName, handler3);
395
396
  if (cedarHandler) {
396
397
  CEDAR_HANDLERS.set(routeName, cedarHandler);
397
398
  } else if (handler3) {
@@ -475,7 +476,10 @@ var init_lambdaLoader = __esm({
475
476
  reply.send(Buffer.from(body));
476
477
  return;
477
478
  }
478
- if (!LAMBDA_FUNCTIONS[routeName]) {
479
+ const handler3 = LAMBDA_FUNCTIONS.get(routeName);
480
+ if (handler3) {
481
+ return requestHandler(req, reply, handler3);
482
+ } else {
479
483
  const errorMessage = `Function "${routeName}" was not found.`;
480
484
  req.log.error(errorMessage);
481
485
  reply.status(404);
@@ -483,10 +487,7 @@ var init_lambdaLoader = __esm({
483
487
  const devError = {
484
488
  error: errorMessage,
485
489
  availableFunctions: [
486
- .../* @__PURE__ */ new Set([
487
- ...Object.keys(LAMBDA_FUNCTIONS),
488
- ...CEDAR_HANDLERS.keys()
489
- ])
490
+ .../* @__PURE__ */ new Set([...LAMBDA_FUNCTIONS.keys(), ...CEDAR_HANDLERS.keys()])
490
491
  ]
491
492
  };
492
493
  reply.send(devError);
@@ -495,7 +496,6 @@ var init_lambdaLoader = __esm({
495
496
  }
496
497
  return;
497
498
  }
498
- return requestHandler(req, reply, LAMBDA_FUNCTIONS[routeName]);
499
499
  };
500
500
  }
501
501
  });
@@ -2,8 +2,7 @@ import type { Handler } from 'aws-lambda';
2
2
  import type { Options as FastGlobOptions } from 'fast-glob';
3
3
  import type { FastifyReply, FastifyRequest, RequestGenericInterface } from 'fastify';
4
4
  import type { CedarHandler, CedarRouteRecord } from '@cedarjs/api/runtime';
5
- export type Lambdas = Record<string, Handler>;
6
- export declare const LAMBDA_FUNCTIONS: Lambdas;
5
+ export declare const LAMBDA_FUNCTIONS: Map<string, Handler | undefined>;
7
6
  export declare const CEDAR_HANDLERS: Map<string, CedarHandler>;
8
7
  /**
9
8
  * Exports a copy of the Cedar route manifest.
@@ -1 +1 @@
1
- {"version":3,"file":"lambdaLoader.d.ts","sourceRoot":"","sources":["../../../src/plugins/lambdaLoader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAEjB,MAAM,sBAAsB,CAAA;AAO7B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,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B,GAAG;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1C,CAAA;AAGD,eAAO,MAAM,qBAAqB,GAChC,UAAS,4BAAiC,kBAe3C,CAAA;AA0BD,UAAU,oBAAqB,SAAQ,uBAAuB;IAC5D,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED;;;;IAII;AACJ,eAAO,MAAM,oBAAoB,GAC/B,KAAK,cAAc,CAAC,oBAAoB,CAAC,EACzC,OAAO,YAAY,kBAqEpB,CAAA"}
@@ -44,7 +44,7 @@ var import_runtime = require("@cedarjs/api/runtime");
44
44
  var import_project_config = require("@cedarjs/project-config");
45
45
  var import_awsLambdaFastify = require("../requestHandlers/awsLambdaFastify.js");
46
46
  var import_utils = require("../utils.js");
47
- const LAMBDA_FUNCTIONS = {};
47
+ const LAMBDA_FUNCTIONS = /* @__PURE__ */ new Map();
48
48
  const CEDAR_HANDLERS = /* @__PURE__ */ new Map();
49
49
  const cedarRouteManifest = [];
50
50
  const getCedarRouteManifest = () => [...cedarRouteManifest];
@@ -52,6 +52,7 @@ const setLambdaFunctions = async (foundFunctions) => {
52
52
  const tsImport = Date.now();
53
53
  console.log(import_ansis.default.dim.italic("Importing Server Functions... "));
54
54
  cedarRouteManifest.length = 0;
55
+ LAMBDA_FUNCTIONS.clear();
55
56
  CEDAR_HANDLERS.clear();
56
57
  const imports = foundFunctions.map(async (fnPath) => {
57
58
  const ts = Date.now();
@@ -78,7 +79,7 @@ const setLambdaFunctions = async (foundFunctions) => {
78
79
  }
79
80
  return void 0;
80
81
  })();
81
- LAMBDA_FUNCTIONS[routeName] = handler;
82
+ LAMBDA_FUNCTIONS.set(routeName, handler);
82
83
  if (cedarHandler) {
83
84
  CEDAR_HANDLERS.set(routeName, cedarHandler);
84
85
  } else if (handler) {
@@ -162,7 +163,10 @@ const lambdaRequestHandler = async (req, reply) => {
162
163
  reply.send(Buffer.from(body));
163
164
  return;
164
165
  }
165
- if (!LAMBDA_FUNCTIONS[routeName]) {
166
+ const handler = LAMBDA_FUNCTIONS.get(routeName);
167
+ if (handler) {
168
+ return (0, import_awsLambdaFastify.requestHandler)(req, reply, handler);
169
+ } else {
166
170
  const errorMessage = `Function "${routeName}" was not found.`;
167
171
  req.log.error(errorMessage);
168
172
  reply.status(404);
@@ -170,10 +174,7 @@ const lambdaRequestHandler = async (req, reply) => {
170
174
  const devError = {
171
175
  error: errorMessage,
172
176
  availableFunctions: [
173
- .../* @__PURE__ */ new Set([
174
- ...Object.keys(LAMBDA_FUNCTIONS),
175
- ...CEDAR_HANDLERS.keys()
176
- ])
177
+ .../* @__PURE__ */ new Set([...LAMBDA_FUNCTIONS.keys(), ...CEDAR_HANDLERS.keys()])
177
178
  ]
178
179
  };
179
180
  reply.send(devError);
@@ -182,7 +183,6 @@ const lambdaRequestHandler = async (req, reply) => {
182
183
  }
183
184
  return;
184
185
  }
185
- return (0, import_awsLambdaFastify.requestHandler)(req, reply, LAMBDA_FUNCTIONS[routeName]);
186
186
  };
187
187
  // Annotate the CommonJS export names for ESM import in node:
188
188
  0 && (module.exports = {
@@ -2,8 +2,7 @@ import type { Handler } from 'aws-lambda';
2
2
  import type { Options as FastGlobOptions } from 'fast-glob';
3
3
  import type { FastifyReply, FastifyRequest, RequestGenericInterface } from 'fastify';
4
4
  import type { CedarHandler, CedarRouteRecord } from '@cedarjs/api/runtime';
5
- export type Lambdas = Record<string, Handler>;
6
- export declare const LAMBDA_FUNCTIONS: Lambdas;
5
+ export declare const LAMBDA_FUNCTIONS: Map<string, Handler | undefined>;
7
6
  export declare const CEDAR_HANDLERS: Map<string, CedarHandler>;
8
7
  /**
9
8
  * Exports a copy of the Cedar route manifest.
@@ -1 +1 @@
1
- {"version":3,"file":"lambdaLoader.d.ts","sourceRoot":"","sources":["../../src/plugins/lambdaLoader.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OA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EhB,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAEjB,MAAM,sBAAsB,CAAA;AAO7B,eAAO,MAAM,gBAAgB,kCAAyC,CAAA;AACtE,eAAO,MAAM,cAAc,2BAAkC,CAAA;AAG7D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,0BAAgC,CAAA;AAIlE,eAAO,MAAM,kBAAkB,GAAU,gBAAgB,MAAM,EAAE,kBAsGhE,CAAA;AAED,KAAK,4BAA4B,GAAG;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC1C,CAAA;AAGD,eAAO,MAAM,qBAAqB,GAChC,UAAS,4BAAiC,kBAe3C,CAAA;AA0BD,UAAU,oBAAqB,SAAQ,uBAAuB;IAC5D,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED;;;;IAII;AACJ,eAAO,MAAM,oBAAoB,GAC/B,KAAK,cAAc,CAAC,oBAAoB,CAAC,EACzC,OAAO,YAAY,kBAqEpB,CAAA"}
@@ -6,7 +6,7 @@ import { buildCedarContext, wrapLegacyHandler } from "@cedarjs/api/runtime";
6
6
  import { getPaths } from "@cedarjs/project-config";
7
7
  import { requestHandler } from "../requestHandlers/awsLambdaFastify.js";
8
8
  import { escape } from "../utils.js";
9
- const LAMBDA_FUNCTIONS = {};
9
+ const LAMBDA_FUNCTIONS = /* @__PURE__ */ new Map();
10
10
  const CEDAR_HANDLERS = /* @__PURE__ */ new Map();
11
11
  const cedarRouteManifest = [];
12
12
  const getCedarRouteManifest = () => [...cedarRouteManifest];
@@ -14,6 +14,7 @@ const setLambdaFunctions = async (foundFunctions) => {
14
14
  const tsImport = Date.now();
15
15
  console.log(ansis.dim.italic("Importing Server Functions... "));
16
16
  cedarRouteManifest.length = 0;
17
+ LAMBDA_FUNCTIONS.clear();
17
18
  CEDAR_HANDLERS.clear();
18
19
  const imports = foundFunctions.map(async (fnPath) => {
19
20
  const ts = Date.now();
@@ -40,7 +41,7 @@ const setLambdaFunctions = async (foundFunctions) => {
40
41
  }
41
42
  return void 0;
42
43
  })();
43
- LAMBDA_FUNCTIONS[routeName] = handler;
44
+ LAMBDA_FUNCTIONS.set(routeName, handler);
44
45
  if (cedarHandler) {
45
46
  CEDAR_HANDLERS.set(routeName, cedarHandler);
46
47
  } else if (handler) {
@@ -124,7 +125,10 @@ const lambdaRequestHandler = async (req, reply) => {
124
125
  reply.send(Buffer.from(body));
125
126
  return;
126
127
  }
127
- if (!LAMBDA_FUNCTIONS[routeName]) {
128
+ const handler = LAMBDA_FUNCTIONS.get(routeName);
129
+ if (handler) {
130
+ return requestHandler(req, reply, handler);
131
+ } else {
128
132
  const errorMessage = `Function "${routeName}" was not found.`;
129
133
  req.log.error(errorMessage);
130
134
  reply.status(404);
@@ -132,10 +136,7 @@ const lambdaRequestHandler = async (req, reply) => {
132
136
  const devError = {
133
137
  error: errorMessage,
134
138
  availableFunctions: [
135
- .../* @__PURE__ */ new Set([
136
- ...Object.keys(LAMBDA_FUNCTIONS),
137
- ...CEDAR_HANDLERS.keys()
138
- ])
139
+ .../* @__PURE__ */ new Set([...LAMBDA_FUNCTIONS.keys(), ...CEDAR_HANDLERS.keys()])
139
140
  ]
140
141
  };
141
142
  reply.send(devError);
@@ -144,7 +145,6 @@ const lambdaRequestHandler = async (req, reply) => {
144
145
  }
145
146
  return;
146
147
  }
147
- return requestHandler(req, reply, LAMBDA_FUNCTIONS[routeName]);
148
148
  };
149
149
  export {
150
150
  CEDAR_HANDLERS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api-server",
3
- "version": "4.0.0-canary.13850+dc6a0f93df",
3
+ "version": "4.0.0-canary.13851+1da55e0595",
4
4
  "description": "CedarJS's HTTP server for Serverless Functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -113,11 +113,11 @@
113
113
  "test:watch": "vitest watch"
114
114
  },
115
115
  "dependencies": {
116
- "@cedarjs/context": "4.0.0-canary.13850",
117
- "@cedarjs/fastify-web": "4.0.0-canary.13850",
118
- "@cedarjs/internal": "4.0.0-canary.13850",
119
- "@cedarjs/project-config": "4.0.0-canary.13850",
120
- "@cedarjs/web-server": "4.0.0-canary.13850",
116
+ "@cedarjs/context": "4.0.0-canary.13851",
117
+ "@cedarjs/fastify-web": "4.0.0-canary.13851",
118
+ "@cedarjs/internal": "4.0.0-canary.13851",
119
+ "@cedarjs/project-config": "4.0.0-canary.13851",
120
+ "@cedarjs/web-server": "4.0.0-canary.13851",
121
121
  "@fastify/multipart": "9.4.0",
122
122
  "@fastify/url-data": "6.0.3",
123
123
  "ansis": "4.2.0",
@@ -134,7 +134,7 @@
134
134
  "yargs": "17.7.2"
135
135
  },
136
136
  "devDependencies": {
137
- "@cedarjs/framework-tools": "4.0.0-canary.13850",
137
+ "@cedarjs/framework-tools": "4.0.0-canary.13851",
138
138
  "@types/aws-lambda": "8.10.161",
139
139
  "@types/dotenv-defaults": "^5.0.0",
140
140
  "@types/split2": "4.2.3",
@@ -147,7 +147,7 @@
147
147
  "vitest": "3.2.4"
148
148
  },
149
149
  "peerDependencies": {
150
- "@cedarjs/graphql-server": "4.0.0-canary.13850"
150
+ "@cedarjs/graphql-server": "4.0.0-canary.13851"
151
151
  },
152
152
  "peerDependenciesMeta": {
153
153
  "@cedarjs/graphql-server": {
@@ -157,5 +157,5 @@
157
157
  "publishConfig": {
158
158
  "access": "public"
159
159
  },
160
- "gitHead": "dc6a0f93df373f5b36a5f061b507af1877e10a77"
160
+ "gitHead": "1da55e05958b7d9ea1961daeb8517222a60fc4b1"
161
161
  }