@cedarjs/api-server 3.0.0-canary.13569 → 3.0.0-canary.13570
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 +15 -15
- package/dist/cjs/bin.js +15 -15
- package/dist/cjs/createServer.js +1 -1
- package/dist/cjs/plugins/api.d.ts +2 -2
- package/dist/cjs/plugins/api.d.ts.map +1 -1
- package/dist/cjs/plugins/api.js +16 -16
- package/dist/cjs/types.d.ts +4 -4
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/createServer.js +2 -2
- package/dist/plugins/api.d.ts +2 -2
- package/dist/plugins/api.d.ts.map +1 -1
- package/dist/plugins/api.js +15 -15
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/bin.js
CHANGED
|
@@ -411,12 +411,12 @@ import fastifyUrlData from "@fastify/url-data";
|
|
|
411
411
|
import fastifyRawBody from "fastify-raw-body";
|
|
412
412
|
import { getAsyncStoreInstance as getAsyncStoreInstance2 } from "@cedarjs/context/dist/store";
|
|
413
413
|
import { coerceRootPath as coerceRootPath2 } from "@cedarjs/fastify-web/dist/helpers.js";
|
|
414
|
-
async function
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
414
|
+
async function cedarFastifyAPI(fastify2, opts) {
|
|
415
|
+
const cedarOptions = opts.redwood ?? {};
|
|
416
|
+
cedarOptions.apiRootPath ??= "/";
|
|
417
|
+
cedarOptions.apiRootPath = coerceRootPath2(cedarOptions.apiRootPath);
|
|
418
|
+
cedarOptions.fastGlobOptions ??= {};
|
|
419
|
+
cedarOptions.loadUserConfig ??= false;
|
|
420
420
|
fastify2.register(fastifyUrlData);
|
|
421
421
|
await fastify2.register(fastifyRawBody);
|
|
422
422
|
fastify2.addHook("onRequest", (_req, _reply, done) => {
|
|
@@ -427,23 +427,23 @@ async function redwoodFastifyAPI(fastify2, opts) {
|
|
|
427
427
|
{ parseAs: "string" },
|
|
428
428
|
fastify2.defaultTextParser
|
|
429
429
|
);
|
|
430
|
-
if (
|
|
430
|
+
if (cedarOptions.loadUserConfig) {
|
|
431
431
|
const { configureFastify } = await loadFastifyConfig();
|
|
432
432
|
if (configureFastify) {
|
|
433
433
|
await configureFastify(fastify2, {
|
|
434
434
|
side: "api",
|
|
435
|
-
apiRootPath:
|
|
435
|
+
apiRootPath: cedarOptions.apiRootPath
|
|
436
436
|
});
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
if (
|
|
440
|
-
await
|
|
439
|
+
if (cedarOptions.configureServer) {
|
|
440
|
+
await cedarOptions.configureServer(fastify2);
|
|
441
441
|
}
|
|
442
|
-
fastify2.all(`${
|
|
443
|
-
fastify2.all(`${
|
|
442
|
+
fastify2.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
|
|
443
|
+
fastify2.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
|
|
444
444
|
await loadFunctionsFromDist({
|
|
445
|
-
fastGlobOptions:
|
|
446
|
-
discoverFunctionsGlob:
|
|
445
|
+
fastGlobOptions: cedarOptions.fastGlobOptions,
|
|
446
|
+
discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
449
|
var init_api = __esm({
|
|
@@ -596,7 +596,7 @@ async function createServer(options = {}) {
|
|
|
596
596
|
server.addHook("onRequest", (_req, _reply, done) => {
|
|
597
597
|
getAsyncStoreInstance4().run(/* @__PURE__ */ new Map(), done);
|
|
598
598
|
});
|
|
599
|
-
await server.register(
|
|
599
|
+
await server.register(cedarFastifyAPI, {
|
|
600
600
|
redwood: {
|
|
601
601
|
apiRootPath,
|
|
602
602
|
fastGlobOptions: {
|
package/dist/cjs/bin.js
CHANGED
|
@@ -429,12 +429,12 @@ var init_lambdaLoader = __esm({
|
|
|
429
429
|
});
|
|
430
430
|
|
|
431
431
|
// src/plugins/api.ts
|
|
432
|
-
async function
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
async function cedarFastifyAPI(fastify2, opts) {
|
|
433
|
+
const cedarOptions = opts.redwood ?? {};
|
|
434
|
+
cedarOptions.apiRootPath ??= "/";
|
|
435
|
+
cedarOptions.apiRootPath = (0, import_helpers2.coerceRootPath)(cedarOptions.apiRootPath);
|
|
436
|
+
cedarOptions.fastGlobOptions ??= {};
|
|
437
|
+
cedarOptions.loadUserConfig ??= false;
|
|
438
438
|
fastify2.register(import_url_data.default);
|
|
439
439
|
await fastify2.register(import_fastify_raw_body.default);
|
|
440
440
|
fastify2.addHook("onRequest", (_req, _reply, done) => {
|
|
@@ -445,23 +445,23 @@ async function redwoodFastifyAPI(fastify2, opts) {
|
|
|
445
445
|
{ parseAs: "string" },
|
|
446
446
|
fastify2.defaultTextParser
|
|
447
447
|
);
|
|
448
|
-
if (
|
|
448
|
+
if (cedarOptions.loadUserConfig) {
|
|
449
449
|
const { configureFastify } = await loadFastifyConfig();
|
|
450
450
|
if (configureFastify) {
|
|
451
451
|
await configureFastify(fastify2, {
|
|
452
452
|
side: "api",
|
|
453
|
-
apiRootPath:
|
|
453
|
+
apiRootPath: cedarOptions.apiRootPath
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
|
-
if (
|
|
458
|
-
await
|
|
457
|
+
if (cedarOptions.configureServer) {
|
|
458
|
+
await cedarOptions.configureServer(fastify2);
|
|
459
459
|
}
|
|
460
|
-
fastify2.all(`${
|
|
461
|
-
fastify2.all(`${
|
|
460
|
+
fastify2.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
|
|
461
|
+
fastify2.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
|
|
462
462
|
await loadFunctionsFromDist({
|
|
463
|
-
fastGlobOptions:
|
|
464
|
-
discoverFunctionsGlob:
|
|
463
|
+
fastGlobOptions: cedarOptions.fastGlobOptions,
|
|
464
|
+
discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
467
|
var import_url_data, import_fastify_raw_body, import_store2, import_helpers2;
|
|
@@ -612,7 +612,7 @@ async function createServer(options = {}) {
|
|
|
612
612
|
server.addHook("onRequest", (_req, _reply, done) => {
|
|
613
613
|
(0, import_store4.getAsyncStoreInstance)().run(/* @__PURE__ */ new Map(), done);
|
|
614
614
|
});
|
|
615
|
-
await server.register(
|
|
615
|
+
await server.register(cedarFastifyAPI, {
|
|
616
616
|
redwood: {
|
|
617
617
|
apiRootPath,
|
|
618
618
|
fastGlobOptions: {
|
package/dist/cjs/createServer.js
CHANGED
|
@@ -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.
|
|
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
|
|
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
|
|
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,
|
|
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"}
|
package/dist/cjs/plugins/api.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 (
|
|
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:
|
|
61
|
+
apiRootPath: cedarOptions.apiRootPath
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
66
|
-
await
|
|
65
|
+
if (cedarOptions.configureServer) {
|
|
66
|
+
await cedarOptions.configureServer(fastify);
|
|
67
67
|
}
|
|
68
|
-
fastify.all(`${
|
|
69
|
-
fastify.all(`${
|
|
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:
|
|
72
|
-
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
|
-
|
|
77
|
+
cedarFastifyAPI
|
|
78
78
|
});
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
import type {
|
|
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<
|
|
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<
|
|
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<
|
|
18
|
+
} & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
|
|
19
19
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/cjs/types.d.ts.map
CHANGED
|
@@ -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,
|
|
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/dist/createServer.js
CHANGED
|
@@ -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 {
|
|
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(
|
|
63
|
+
await server.register(cedarFastifyAPI, {
|
|
64
64
|
redwood: {
|
|
65
65
|
apiRootPath,
|
|
66
66
|
fastGlobOptions: {
|
package/dist/plugins/api.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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,
|
|
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"}
|
package/dist/plugins/api.js
CHANGED
|
@@ -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
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 (
|
|
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:
|
|
28
|
+
apiRootPath: cedarOptions.apiRootPath
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
if (
|
|
33
|
-
await
|
|
32
|
+
if (cedarOptions.configureServer) {
|
|
33
|
+
await cedarOptions.configureServer(fastify);
|
|
34
34
|
}
|
|
35
|
-
fastify.all(`${
|
|
36
|
-
fastify.all(`${
|
|
35
|
+
fastify.all(`${cedarOptions.apiRootPath}:routeName`, lambdaRequestHandler);
|
|
36
|
+
fastify.all(`${cedarOptions.apiRootPath}:routeName/*`, lambdaRequestHandler);
|
|
37
37
|
await loadFunctionsFromDist({
|
|
38
|
-
fastGlobOptions:
|
|
39
|
-
discoverFunctionsGlob:
|
|
38
|
+
fastGlobOptions: cedarOptions.fastGlobOptions,
|
|
39
|
+
discoverFunctionsGlob: cedarOptions.discoverFunctionsGlob
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
export {
|
|
43
|
-
|
|
43
|
+
cedarFastifyAPI
|
|
44
44
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
import type {
|
|
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<
|
|
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<
|
|
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<
|
|
18
|
+
} & Omit<CedarFastifyAPIOptions['redwood'], 'fastGlobOptions'>;
|
|
19
19
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,
|
|
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": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13570+49584f549",
|
|
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": "3.0.0-canary.
|
|
115
|
-
"@cedarjs/fastify-web": "3.0.0-canary.
|
|
116
|
-
"@cedarjs/internal": "3.0.0-canary.
|
|
117
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
118
|
-
"@cedarjs/web-server": "3.0.0-canary.
|
|
114
|
+
"@cedarjs/context": "3.0.0-canary.13570",
|
|
115
|
+
"@cedarjs/fastify-web": "3.0.0-canary.13570",
|
|
116
|
+
"@cedarjs/internal": "3.0.0-canary.13570",
|
|
117
|
+
"@cedarjs/project-config": "3.0.0-canary.13570",
|
|
118
|
+
"@cedarjs/web-server": "3.0.0-canary.13570",
|
|
119
119
|
"@fastify/multipart": "9.4.0",
|
|
120
120
|
"@fastify/url-data": "6.0.3",
|
|
121
121
|
"ansis": "4.2.0",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"yargs": "17.7.2"
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
|
-
"@cedarjs/framework-tools": "3.0.0-canary.
|
|
135
|
+
"@cedarjs/framework-tools": "3.0.0-canary.13570",
|
|
136
136
|
"@types/aws-lambda": "8.10.161",
|
|
137
137
|
"@types/dotenv-defaults": "^5.0.0",
|
|
138
138
|
"@types/qs": "6.15.0",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"vitest": "3.2.4"
|
|
147
147
|
},
|
|
148
148
|
"peerDependencies": {
|
|
149
|
-
"@cedarjs/graphql-server": "3.0.0-canary.
|
|
149
|
+
"@cedarjs/graphql-server": "3.0.0-canary.13570"
|
|
150
150
|
},
|
|
151
151
|
"peerDependenciesMeta": {
|
|
152
152
|
"@cedarjs/graphql-server": {
|
|
@@ -156,5 +156,5 @@
|
|
|
156
156
|
"publishConfig": {
|
|
157
157
|
"access": "public"
|
|
158
158
|
},
|
|
159
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "49584f549384bc0599312a5996dda2e1bebcef14"
|
|
160
160
|
}
|