@cedarjs/api-server 5.0.6 → 5.0.7-next.219
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/README.md +0 -1
- package/dist/apiCLIConfig.d.ts.map +1 -1
- package/dist/apiCLIConfig.js +1 -1
- package/dist/apiCLIConfigHandler.d.ts.map +1 -1
- package/dist/apiCLIConfigHandler.js +5 -0
- package/dist/bin.js +130 -43
- package/dist/bothCLIConfig.d.ts.map +1 -1
- package/dist/bothCLIConfig.js +2 -2
- package/dist/bothCLIConfigHandler.d.ts.map +1 -1
- package/dist/bothCLIConfigHandler.js +8 -2
- package/dist/cliHelpers.d.ts +21 -4
- package/dist/cliHelpers.d.ts.map +1 -1
- package/dist/cliHelpers.js +39 -11
- package/dist/createServer.d.ts.map +1 -1
- package/dist/createServer.js +4 -4
- package/dist/createServerHelpers.d.ts.map +1 -1
- package/dist/createServerHelpers.js +6 -2
- package/dist/logFormatter/formatters.d.ts.map +1 -1
- package/dist/plugins/api.d.ts +1 -1
- package/dist/plugins/api.d.ts.map +1 -1
- package/dist/plugins/api.js +1 -1
- package/dist/plugins/graphql.d.ts +3 -3
- package/dist/plugins/graphql.d.ts.map +1 -1
- package/dist/plugins/graphql.js +14 -12
- package/dist/plugins/lambdaLoader.d.ts.map +1 -1
- package/dist/serverFile.d.ts +23 -0
- package/dist/serverFile.d.ts.map +1 -0
- package/dist/serverFile.js +35 -0
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -20
- package/package.json +36 -77
- package/dist/buildManager.d.ts +0 -15
- package/dist/buildManager.d.ts.map +0 -1
- package/dist/buildManager.js +0 -55
- package/dist/cjs/apiCLIConfig.d.ts +0 -6
- package/dist/cjs/apiCLIConfig.d.ts.map +0 -1
- package/dist/cjs/apiCLIConfig.js +0 -71
- package/dist/cjs/apiCLIConfigHandler.d.ts +0 -3
- package/dist/cjs/apiCLIConfigHandler.d.ts.map +0 -1
- package/dist/cjs/apiCLIConfigHandler.js +0 -67
- package/dist/cjs/bin.d.ts +0 -2
- package/dist/cjs/bin.d.ts.map +0 -1
- package/dist/cjs/bin.js +0 -1002
- package/dist/cjs/bothCLIConfig.d.ts +0 -6
- package/dist/cjs/bothCLIConfig.d.ts.map +0 -1
- package/dist/cjs/bothCLIConfig.js +0 -76
- package/dist/cjs/bothCLIConfigHandler.d.ts +0 -3
- package/dist/cjs/bothCLIConfigHandler.d.ts.map +0 -1
- package/dist/cjs/bothCLIConfigHandler.js +0 -107
- package/dist/cjs/buildManager.d.ts +0 -15
- package/dist/cjs/buildManager.d.ts.map +0 -1
- package/dist/cjs/buildManager.js +0 -79
- package/dist/cjs/cliHelpers.d.ts +0 -6
- package/dist/cjs/cliHelpers.d.ts.map +0 -1
- package/dist/cjs/cliHelpers.js +0 -57
- package/dist/cjs/createServer.d.ts +0 -30
- package/dist/cjs/createServer.d.ts.map +0 -1
- package/dist/cjs/createServer.js +0 -145
- package/dist/cjs/createServerHelpers.d.ts +0 -38
- package/dist/cjs/createServerHelpers.d.ts.map +0 -1
- package/dist/cjs/createServerHelpers.js +0 -112
- package/dist/cjs/fastify.d.ts +0 -13
- package/dist/cjs/fastify.d.ts.map +0 -1
- package/dist/cjs/fastify.js +0 -96
- package/dist/cjs/logFormatter/ambient.d.js +0 -1
- package/dist/cjs/logFormatter/bin.d.ts +0 -2
- package/dist/cjs/logFormatter/bin.d.ts.map +0 -1
- package/dist/cjs/logFormatter/bin.js +0 -369
- package/dist/cjs/logFormatter/formatters.d.ts +0 -30
- package/dist/cjs/logFormatter/formatters.d.ts.map +0 -1
- package/dist/cjs/logFormatter/formatters.js +0 -275
- package/dist/cjs/logFormatter/index.d.ts +0 -2
- package/dist/cjs/logFormatter/index.d.ts.map +0 -1
- package/dist/cjs/logFormatter/index.js +0 -184
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/plugins/api.d.ts +0 -14
- package/dist/cjs/plugins/api.d.ts.map +0 -1
- package/dist/cjs/plugins/api.js +0 -78
- package/dist/cjs/plugins/graphql.d.ts +0 -10
- package/dist/cjs/plugins/graphql.d.ts.map +0 -1
- package/dist/cjs/plugins/graphql.js +0 -135
- package/dist/cjs/plugins/lambdaLoader.d.ts +0 -34
- package/dist/cjs/plugins/lambdaLoader.d.ts.map +0 -1
- package/dist/cjs/plugins/lambdaLoader.js +0 -199
- package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts +0 -5
- package/dist/cjs/requestHandlers/awsLambdaFastify.d.ts.map +0 -1
- package/dist/cjs/requestHandlers/awsLambdaFastify.js +0 -105
- package/dist/cjs/requestHandlers/utils.d.ts +0 -26
- package/dist/cjs/requestHandlers/utils.d.ts.map +0 -1
- package/dist/cjs/requestHandlers/utils.js +0 -55
- package/dist/cjs/serverManager.d.ts +0 -8
- package/dist/cjs/serverManager.d.ts.map +0 -1
- package/dist/cjs/serverManager.js +0 -137
- package/dist/cjs/types.d.ts +0 -19
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/utils.d.ts +0 -6
- package/dist/cjs/utils.d.ts.map +0 -1
- package/dist/cjs/utils.js +0 -58
- package/dist/cjs/watch.d.ts +0 -10
- package/dist/cjs/watch.d.ts.map +0 -1
- package/dist/cjs/watch.js +0 -399
- package/dist/cjs/watchPaths.d.ts +0 -3
- package/dist/cjs/watchPaths.d.ts.map +0 -1
- package/dist/cjs/watchPaths.js +0 -140
- package/dist/serverManager.d.ts +0 -8
- package/dist/serverManager.d.ts.map +0 -1
- package/dist/serverManager.js +0 -102
- package/dist/watch.d.ts +0 -10
- package/dist/watch.d.ts.map +0 -1
- package/dist/watch.js +0 -375
- package/dist/watchPaths.d.ts +0 -3
- package/dist/watchPaths.d.ts.map +0 -1
- package/dist/watchPaths.js +0 -109
package/dist/plugins/graphql.js
CHANGED
|
@@ -2,16 +2,16 @@ import { pathToFileURL } from "node:url";
|
|
|
2
2
|
import fastifyMultiPart from "@fastify/multipart";
|
|
3
3
|
import fastifyUrlData from "@fastify/url-data";
|
|
4
4
|
import fg from "fast-glob";
|
|
5
|
-
import { buildCedarContext
|
|
5
|
+
import { buildCedarContext } from "@cedarjs/api/runtime";
|
|
6
6
|
import { getAsyncStoreInstance } from "@cedarjs/context/dist/store";
|
|
7
7
|
import { coerceRootPath } from "@cedarjs/fastify-web/dist/helpers.js";
|
|
8
8
|
import { createGraphQLYoga } from "@cedarjs/graphql-server";
|
|
9
9
|
import { getPaths } from "@cedarjs/project-config";
|
|
10
10
|
import { lambdaEventForFastifyRequest } from "../requestHandlers/awsLambdaFastify.js";
|
|
11
|
-
async function
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
async function cedarFastifyGraphQLServer(fastify, options) {
|
|
12
|
+
const cedarOptions = options.cedar ?? {};
|
|
13
|
+
cedarOptions.apiRootPath ??= "/";
|
|
14
|
+
cedarOptions.apiRootPath = coerceRootPath(cedarOptions.apiRootPath);
|
|
15
15
|
fastify.register(fastifyUrlData);
|
|
16
16
|
fastify.register(fastifyMultiPart);
|
|
17
17
|
const method = ["GET", "POST", "OPTIONS"];
|
|
@@ -19,7 +19,7 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
|
|
|
19
19
|
getAsyncStoreInstance().run(/* @__PURE__ */ new Map(), done);
|
|
20
20
|
});
|
|
21
21
|
try {
|
|
22
|
-
if (!
|
|
22
|
+
if (!cedarOptions.graphql) {
|
|
23
23
|
const [graphqlFunctionPath] = await fg("dist/functions/graphql.{ts,js}", {
|
|
24
24
|
cwd: getPaths().api.base,
|
|
25
25
|
absolute: true
|
|
@@ -29,9 +29,9 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
|
|
|
29
29
|
if (!__cedar_graphqlOptions) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
cedarOptions.graphql = __cedar_graphqlOptions;
|
|
33
33
|
}
|
|
34
|
-
const graphqlOptions =
|
|
34
|
+
const graphqlOptions = cedarOptions.graphql;
|
|
35
35
|
if (graphqlOptions?.realtime?.subscriptions) {
|
|
36
36
|
method.push("PUT");
|
|
37
37
|
}
|
|
@@ -40,12 +40,12 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
|
|
|
40
40
|
const routePaths = ["", "/health", "/readiness", "/stream"];
|
|
41
41
|
for (const routePath of routePaths) {
|
|
42
42
|
fastify.route({
|
|
43
|
-
url: `${
|
|
43
|
+
url: `${cedarOptions.apiRootPath}${graphqlEndpoint}${routePath}`,
|
|
44
44
|
method,
|
|
45
45
|
handler: async (req, reply) => {
|
|
46
46
|
const request = createFetchRequest(req, reply);
|
|
47
47
|
const cedarContext = await buildCedarContext(request, {
|
|
48
|
-
authDecoder: graphqlOptions.authDecoder
|
|
48
|
+
authDecoder: graphqlOptions.authDecoder
|
|
49
49
|
});
|
|
50
50
|
try {
|
|
51
51
|
return await yoga.handle(request, {
|
|
@@ -74,7 +74,9 @@ async function redwoodFastifyGraphQLServer(fastify, options) {
|
|
|
74
74
|
done();
|
|
75
75
|
});
|
|
76
76
|
} catch (e) {
|
|
77
|
-
|
|
77
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
78
|
+
fastify.log.error(e, `Failed to set up the GraphQL server: ${message}`);
|
|
79
|
+
throw e;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
function trimSlashes(path) {
|
|
@@ -97,5 +99,5 @@ function createFetchRequest(req, reply) {
|
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
export {
|
|
100
|
-
|
|
102
|
+
cedarFastifyGraphQLServer
|
|
101
103
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambdaLoader.d.ts","sourceRoot":"","sources":["../../src/plugins/lambdaLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lambdaLoader.d.ts","sourceRoot":"","sources":["../../src/plugins/lambdaLoader.ts"],"names":[],"mappings":"AAIA,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;AAGhB,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAEjB,MAAM,sBAAsB,CAAA;AAO7B,eAAO,MAAM,gBAAgB,sBAA6B,CAAA;AAC1D,eAAO,MAAM,cAAc,2BAAkC,CAAA;AAG7D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,0BAAgC,CAAA;AAIlE,eAAO,MAAM,kBAAkB,GAAU,gBAAgB,MAAM,EAAE,kBAuGhE,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;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,cAAc,CAAC,oBAAoB,CAAC,EACzC,OAAO,YAAY,kBAqEpB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { APIParsedOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Path to a project's built custom server file, if it has one.
|
|
4
|
+
*
|
|
5
|
+
* This checks `api/dist/server.js` — the built output — not
|
|
6
|
+
* `api/src/server.{ts,js}`, which is what `@cedarjs/cli`'s own
|
|
7
|
+
* `serverFileExists()` checks. A production install typically ships only
|
|
8
|
+
* `api/dist`, so checking source would return false in exactly the
|
|
9
|
+
* situation this needs to catch.
|
|
10
|
+
*/
|
|
11
|
+
export declare function apiDistServerFilePath(): string;
|
|
12
|
+
export declare function apiDistServerFileExists(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Run a project's custom `api/dist/server.js` instead of the default Fastify
|
|
15
|
+
* server.
|
|
16
|
+
*
|
|
17
|
+
* Reimplements what `@cedarjs/cli`'s `apiServerFileHandler` does for
|
|
18
|
+
* `cedar serve api`, rather than importing it — `@cedarjs/cli` pulls in its
|
|
19
|
+
* whole build/dev toolchain, which is exactly what a production install of
|
|
20
|
+
* this package needs to stay clear of.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runApiDistServerFile(options?: APIParsedOptions): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=serverFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFile.d.ts","sourceRoot":"","sources":["../src/serverFile.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
function apiDistServerFilePath() {
|
|
6
|
+
return path.join(getPaths().api.dist, "server.js");
|
|
7
|
+
}
|
|
8
|
+
function apiDistServerFileExists() {
|
|
9
|
+
return fs.existsSync(apiDistServerFilePath());
|
|
10
|
+
}
|
|
11
|
+
async function runApiDistServerFile(options = {}) {
|
|
12
|
+
const args = ["--apiRootPath", options.apiRootPath ?? "/"];
|
|
13
|
+
if (options.port !== void 0) {
|
|
14
|
+
args.push("--apiPort", String(options.port));
|
|
15
|
+
}
|
|
16
|
+
await new Promise((resolve, reject) => {
|
|
17
|
+
const child = spawn(process.execPath, [apiDistServerFilePath(), ...args], {
|
|
18
|
+
cwd: getPaths().api.dist,
|
|
19
|
+
stdio: "inherit"
|
|
20
|
+
});
|
|
21
|
+
child.on("error", reject);
|
|
22
|
+
child.on("exit", (code, signal) => {
|
|
23
|
+
if (signal || code === 0) {
|
|
24
|
+
resolve();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
reject(new Error(`api/dist/server.js exited with code ${code}`));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
apiDistServerFileExists,
|
|
33
|
+
apiDistServerFilePath,
|
|
34
|
+
runApiDistServerFile
|
|
35
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ 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<CedarFastifyAPIOptions['
|
|
6
|
+
export type FastifySideConfigFn = (fastify: FastifyInstance, options?: FastifySideConfigFnOptions & Pick<CedarFastifyAPIOptions['cedar'], 'apiRootPath'>) => Promise<FastifyInstance> | void;
|
|
7
7
|
export type APIParsedOptions = {
|
|
8
8
|
port?: number;
|
|
9
9
|
host?: string;
|
|
10
10
|
loadEnvFiles?: boolean;
|
|
11
|
-
} & Omit<CedarFastifyAPIOptions['
|
|
11
|
+
} & Omit<CedarFastifyAPIOptions['cedar'], '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<CedarFastifyAPIOptions['
|
|
18
|
+
} & Omit<CedarFastifyAPIOptions['cedar'], '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,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,
|
|
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,OAAO,CAAC,EAAE,aAAa,CAAC,KACnD,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,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAE5D,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,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAA"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number): T & {
|
|
2
|
-
cancel: () => void;
|
|
3
|
-
};
|
|
4
1
|
/** Escapes HTML characters to prevent XSS attacks */
|
|
5
2
|
export declare function escape(string: string): string;
|
|
6
3
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU7C"}
|
package/dist/utils.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
function debounce(func, wait) {
|
|
2
|
-
let timeoutId = null;
|
|
3
|
-
const debounced = ((...args) => {
|
|
4
|
-
if (timeoutId !== null) {
|
|
5
|
-
clearTimeout(timeoutId);
|
|
6
|
-
}
|
|
7
|
-
timeoutId = setTimeout(() => {
|
|
8
|
-
timeoutId = null;
|
|
9
|
-
func(...args);
|
|
10
|
-
}, wait);
|
|
11
|
-
});
|
|
12
|
-
debounced.cancel = () => {
|
|
13
|
-
if (timeoutId !== null) {
|
|
14
|
-
clearTimeout(timeoutId);
|
|
15
|
-
timeoutId = null;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
return debounced;
|
|
19
|
-
}
|
|
20
1
|
function escape(string) {
|
|
21
2
|
const htmlEscapes = {
|
|
22
3
|
"&": "&",
|
|
@@ -28,6 +9,5 @@ function escape(string) {
|
|
|
28
9
|
return string.replace(/[&<>"']/g, (char) => htmlEscapes[char]);
|
|
29
10
|
}
|
|
30
11
|
export {
|
|
31
|
-
debounce,
|
|
32
12
|
escape
|
|
33
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/api-server",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7-next.219",
|
|
4
4
|
"description": "CedarJS's HTTP server for Serverless Functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,110 +11,70 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
14
|
+
"default": {
|
|
15
15
|
"types": "./dist/createServer.d.ts",
|
|
16
16
|
"default": "./dist/createServer.js"
|
|
17
|
-
},
|
|
18
|
-
"require": {
|
|
19
|
-
"types": "./dist/cjs/createServer.d.ts",
|
|
20
|
-
"default": "./dist/cjs/createServer.js"
|
|
21
17
|
}
|
|
22
18
|
},
|
|
23
19
|
"./package.json": "./package.json",
|
|
24
20
|
"./apiCliConfig": {
|
|
25
|
-
"
|
|
21
|
+
"default": {
|
|
26
22
|
"types": "./dist/apiCLIConfig.d.ts",
|
|
27
23
|
"default": "./dist/apiCLIConfig.js"
|
|
28
|
-
},
|
|
29
|
-
"require": {
|
|
30
|
-
"types": "./dist/cjs/apiCLIConfig.d.ts",
|
|
31
|
-
"default": "./dist/cjs/apiCLIConfig.js"
|
|
32
24
|
}
|
|
33
25
|
},
|
|
34
26
|
"./bothCliConfig": {
|
|
35
|
-
"
|
|
27
|
+
"default": {
|
|
36
28
|
"types": "./dist/bothCLIConfig.d.ts",
|
|
37
29
|
"default": "./dist/bothCLIConfig.js"
|
|
38
|
-
},
|
|
39
|
-
"require": {
|
|
40
|
-
"types": "./dist/cjs/bothCLIConfig.d.ts",
|
|
41
|
-
"default": "./dist/cjs/bothCLIConfig.js"
|
|
42
30
|
}
|
|
43
31
|
},
|
|
44
32
|
"./apiCliConfigHandler": {
|
|
45
|
-
"
|
|
33
|
+
"default": {
|
|
46
34
|
"types": "./dist/apiCLIConfigHandler.d.ts",
|
|
47
35
|
"default": "./dist/apiCLIConfigHandler.js"
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"./bothCliConfigHandler": {
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./dist/bothCLIConfigHandler.d.ts",
|
|
41
|
+
"default": "./dist/bothCLIConfigHandler.js"
|
|
52
42
|
}
|
|
53
43
|
},
|
|
54
44
|
"./cliHelpers": {
|
|
55
|
-
"
|
|
45
|
+
"default": {
|
|
56
46
|
"types": "./dist/cliHelpers.d.ts",
|
|
57
47
|
"default": "./dist/cliHelpers.js"
|
|
58
|
-
},
|
|
59
|
-
"require": {
|
|
60
|
-
"types": "./dist/cjs/cliHelpers.d.ts",
|
|
61
|
-
"default": "./dist/cjs/cliHelpers.js"
|
|
62
48
|
}
|
|
63
49
|
},
|
|
64
|
-
"./cjs/apiCliConfigHandler": {
|
|
65
|
-
"types": "./dist/cjs/apiCLIConfigHandler.d.ts",
|
|
66
|
-
"default": "./dist/cjs/apiCLIConfigHandler.js"
|
|
67
|
-
},
|
|
68
|
-
"./cjs/cliHelpers": {
|
|
69
|
-
"types": "./dist/cjs/cliHelpers.d.ts",
|
|
70
|
-
"default": "./dist/cjs/cliHelpers.js"
|
|
71
|
-
},
|
|
72
|
-
"./cjs/bothCliConfigHandler": {
|
|
73
|
-
"types": "./dist/cjs/bothCLIConfigHandler.d.ts",
|
|
74
|
-
"default": "./dist/cjs/bothCLIConfigHandler.js"
|
|
75
|
-
},
|
|
76
50
|
"./fastify": {
|
|
77
|
-
"
|
|
51
|
+
"default": {
|
|
78
52
|
"types": "./dist/fastify.d.ts",
|
|
79
53
|
"default": "./dist/fastify.js"
|
|
80
|
-
},
|
|
81
|
-
"require": {
|
|
82
|
-
"types": "./dist/cjs/fastify.d.ts",
|
|
83
|
-
"default": "./dist/cjs/fastify.js"
|
|
84
54
|
}
|
|
85
55
|
},
|
|
86
|
-
"./
|
|
87
|
-
"
|
|
88
|
-
"types": "./dist/
|
|
89
|
-
"default": "./dist/
|
|
90
|
-
},
|
|
91
|
-
"require": {
|
|
92
|
-
"types": "./dist/cjs/watch.d.ts",
|
|
93
|
-
"default": "./dist/cjs/watch.js"
|
|
56
|
+
"./logFormatter": {
|
|
57
|
+
"default": {
|
|
58
|
+
"types": "./dist/logFormatter/index.d.ts",
|
|
59
|
+
"default": "./dist/logFormatter/index.js"
|
|
94
60
|
}
|
|
95
61
|
},
|
|
96
62
|
"./requestHandlers": {
|
|
97
|
-
"
|
|
63
|
+
"default": {
|
|
98
64
|
"types": "./dist/requestHandlers/awsLambdaFastify.d.ts",
|
|
99
65
|
"default": "./dist/requestHandlers/awsLambdaFastify.js"
|
|
100
|
-
},
|
|
101
|
-
"require": {
|
|
102
|
-
"types": "./dist/cjs/requestHandlers/awsLambdaFastify.d.ts",
|
|
103
|
-
"default": "./dist/cjs/requestHandlers/awsLambdaFastify.js"
|
|
104
66
|
}
|
|
105
67
|
}
|
|
106
68
|
},
|
|
107
69
|
"main": "./dist/createServer.js",
|
|
108
70
|
"types": "./dist/createServer.d.ts",
|
|
109
71
|
"bin": {
|
|
110
|
-
"cedar-
|
|
111
|
-
"cedar-
|
|
112
|
-
"cedar-server": "./dist/cjs/bin.js",
|
|
113
|
-
"cedarjs-api-server-watch": "./dist/watch.js",
|
|
72
|
+
"cedar-log-formatter": "./dist/logFormatter/bin.js",
|
|
73
|
+
"cedar-server": "./dist/bin.js",
|
|
114
74
|
"cedarjs-log-formatter": "./dist/logFormatter/bin.js",
|
|
115
75
|
"cedarjs-server": "./dist/bin.js",
|
|
116
|
-
"rw-log-formatter": "./dist/
|
|
117
|
-
"rw-server": "./dist/
|
|
76
|
+
"rw-log-formatter": "./dist/logFormatter/bin.js",
|
|
77
|
+
"rw-server": "./dist/bin.js"
|
|
118
78
|
},
|
|
119
79
|
"files": [
|
|
120
80
|
"dist"
|
|
@@ -123,29 +83,27 @@
|
|
|
123
83
|
"build": "node ./build.mts",
|
|
124
84
|
"build:pack": "yarn pack -o cedarjs-api-server.tgz",
|
|
125
85
|
"build:types": "tsc --build --verbose tsconfig.build.json",
|
|
126
|
-
"build:types-cjs": "tsc --build --verbose tsconfig.cjs.json",
|
|
127
86
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build && yarn fix:permissions\"",
|
|
128
87
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
129
88
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
130
|
-
"fix:permissions": "chmod +x dist/index.js
|
|
89
|
+
"fix:permissions": "chmod +x dist/index.js",
|
|
131
90
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
132
91
|
"test": "vitest run",
|
|
133
92
|
"test:watch": "vitest watch"
|
|
134
93
|
},
|
|
135
94
|
"dependencies": {
|
|
136
|
-
"@cedarjs/
|
|
137
|
-
"@cedarjs/
|
|
138
|
-
"@cedarjs/
|
|
139
|
-
"@cedarjs/project-config": "5.0.
|
|
140
|
-
"@cedarjs/web-server": "5.0.
|
|
95
|
+
"@cedarjs/api": "5.0.7-next.219",
|
|
96
|
+
"@cedarjs/context": "5.0.7-next.219",
|
|
97
|
+
"@cedarjs/fastify-web": "5.0.7-next.219",
|
|
98
|
+
"@cedarjs/project-config": "5.0.7-next.219",
|
|
99
|
+
"@cedarjs/web-server": "5.0.7-next.219",
|
|
141
100
|
"@fastify/multipart": "9.4.0",
|
|
142
101
|
"@fastify/url-data": "6.0.3",
|
|
143
|
-
"ansis": "4.
|
|
144
|
-
"chokidar": "3.6.0",
|
|
102
|
+
"ansis": "4.3.1",
|
|
145
103
|
"dotenv-defaults": "5.0.2",
|
|
146
104
|
"fast-glob": "3.3.3",
|
|
147
105
|
"fast-json-parse": "1.0.3",
|
|
148
|
-
"fastify": "5.
|
|
106
|
+
"fastify": "5.10.0",
|
|
149
107
|
"fastify-raw-body": "5.0.0",
|
|
150
108
|
"picoquery": "2.5.0",
|
|
151
109
|
"pretty-bytes": "5.6.0",
|
|
@@ -155,21 +113,22 @@
|
|
|
155
113
|
"yargs": "17.7.3"
|
|
156
114
|
},
|
|
157
115
|
"devDependencies": {
|
|
158
|
-
"@cedarjs/framework-tools": "5.0.
|
|
116
|
+
"@cedarjs/framework-tools": "5.0.7-next.219",
|
|
159
117
|
"@types/aws-lambda": "8.10.162",
|
|
160
118
|
"@types/dotenv-defaults": "^5.0.0",
|
|
161
119
|
"@types/split2": "4.2.3",
|
|
162
120
|
"@types/yargs": "17.0.35",
|
|
163
121
|
"concurrently": "9.2.4",
|
|
164
|
-
"
|
|
122
|
+
"esbuild": "0.28.1",
|
|
165
123
|
"memfs": "4.64.0",
|
|
124
|
+
"pino": "9.7.0",
|
|
166
125
|
"pino-abstract-transport": "1.2.0",
|
|
167
|
-
"publint": "0.3.
|
|
126
|
+
"publint": "0.3.22",
|
|
168
127
|
"typescript": "5.9.3",
|
|
169
|
-
"vitest": "
|
|
128
|
+
"vitest": "4.1.10"
|
|
170
129
|
},
|
|
171
130
|
"peerDependencies": {
|
|
172
|
-
"@cedarjs/graphql-server": "5.0.
|
|
131
|
+
"@cedarjs/graphql-server": "5.0.7-next.219"
|
|
173
132
|
},
|
|
174
133
|
"peerDependenciesMeta": {
|
|
175
134
|
"@cedarjs/graphql-server": {
|
package/dist/buildManager.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type BuildAndRestartOptions = {
|
|
2
|
-
rebuild?: boolean;
|
|
3
|
-
clean?: boolean;
|
|
4
|
-
};
|
|
5
|
-
declare class BuildManager {
|
|
6
|
-
private shouldRebuild;
|
|
7
|
-
private shouldClean;
|
|
8
|
-
private debouncedBuild;
|
|
9
|
-
private buildFn;
|
|
10
|
-
constructor(buildFn: (options: BuildAndRestartOptions) => Promise<void>);
|
|
11
|
-
run(options: BuildAndRestartOptions): Promise<void>;
|
|
12
|
-
cancelScheduledBuild(): void;
|
|
13
|
-
}
|
|
14
|
-
export { BuildManager };
|
|
15
|
-
//# sourceMappingURL=buildManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildManager.d.ts","sourceRoot":"","sources":["../src/buildManager.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,OAAO,CAAoD;gBAEvD,OAAO,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC;IAsCjE,GAAG,CAAC,OAAO,EAAE,sBAAsB;IAWzC,oBAAoB;CAGrB;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/buildManager.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { debounce } from "./utils.js";
|
|
2
|
-
class BuildManager {
|
|
3
|
-
shouldRebuild;
|
|
4
|
-
shouldClean;
|
|
5
|
-
debouncedBuild;
|
|
6
|
-
buildFn;
|
|
7
|
-
constructor(buildFn) {
|
|
8
|
-
this.shouldRebuild = true;
|
|
9
|
-
this.shouldClean = false;
|
|
10
|
-
this.buildFn = buildFn;
|
|
11
|
-
if (process.env.RWJS_DELAY_RESTART) {
|
|
12
|
-
console.warn(
|
|
13
|
-
"[DEPRECATED] RWJS_DELAY_RESTART is deprecated and will be removed in the next major release. Please rename it to CEDAR_DELAY_API_RESTART in your .env file."
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
const delay = process.env.CEDAR_DELAY_API_RESTART || process.env.RWJS_DELAY_RESTART;
|
|
17
|
-
this.debouncedBuild = debounce(
|
|
18
|
-
async (options) => {
|
|
19
|
-
try {
|
|
20
|
-
await this.buildFn({
|
|
21
|
-
...options,
|
|
22
|
-
rebuild: this.shouldRebuild,
|
|
23
|
-
clean: this.shouldClean
|
|
24
|
-
});
|
|
25
|
-
} finally {
|
|
26
|
-
this.shouldRebuild = true;
|
|
27
|
-
this.shouldClean = false;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
// We want to delay execution when multiple files are modified on the
|
|
31
|
-
// filesystem. This usually happens when running Cedar generator commands.
|
|
32
|
-
// Local writes are very fast, but writes in e2e environments are not, so
|
|
33
|
-
// allow the default to be adjusted with an env-var.
|
|
34
|
-
delay ? parseInt(delay, 10) : 500
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
// Wrapper method to handle options and set precedence flags.
|
|
38
|
-
// If we ever see a `rebuild: false` option while debouncing, we never want to rebuild.
|
|
39
|
-
// If we ever see a `clean: true` option, we always want to clean.
|
|
40
|
-
async run(options) {
|
|
41
|
-
if (options.rebuild === false) {
|
|
42
|
-
this.shouldRebuild = false;
|
|
43
|
-
}
|
|
44
|
-
if (options.clean) {
|
|
45
|
-
this.shouldClean = true;
|
|
46
|
-
}
|
|
47
|
-
await this.debouncedBuild(options);
|
|
48
|
-
}
|
|
49
|
-
cancelScheduledBuild() {
|
|
50
|
-
this.debouncedBuild.cancel();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
BuildManager
|
|
55
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Argv } from 'yargs';
|
|
2
|
-
import type { APIParsedOptions } from './types.js';
|
|
3
|
-
export declare const description = "Start a server for serving the api side";
|
|
4
|
-
export declare function builder(yargs: Argv<APIParsedOptions>): void;
|
|
5
|
-
export declare function handler(options: APIParsedOptions): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=apiCLIConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiCLIConfig.d.ts","sourceRoot":"","sources":["../../src/apiCLIConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,eAAO,MAAM,WAAW,4CAA4C,CAAA;AAEpE,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,QA0BpD;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,gBAAgB,iBAGtD"}
|
package/dist/cjs/apiCLIConfig.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
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
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var apiCLIConfig_exports = {};
|
|
30
|
-
__export(apiCLIConfig_exports, {
|
|
31
|
-
builder: () => builder,
|
|
32
|
-
description: () => description,
|
|
33
|
-
handler: () => handler
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(apiCLIConfig_exports);
|
|
36
|
-
const description = "Start a server for serving the api side";
|
|
37
|
-
function builder(yargs) {
|
|
38
|
-
yargs.options({
|
|
39
|
-
port: {
|
|
40
|
-
description: "The port to listen at",
|
|
41
|
-
type: "number",
|
|
42
|
-
alias: "p"
|
|
43
|
-
},
|
|
44
|
-
host: {
|
|
45
|
-
description: "The host to listen at. Note that you most likely want this to be '0.0.0.0' in production",
|
|
46
|
-
type: "string"
|
|
47
|
-
},
|
|
48
|
-
apiRootPath: {
|
|
49
|
-
description: "Root path where your api functions are served",
|
|
50
|
-
type: "string",
|
|
51
|
-
alias: ["api-root-path", "rootPath", "root-path"],
|
|
52
|
-
default: "/"
|
|
53
|
-
},
|
|
54
|
-
// This became a no-op in v7 because env files weren't loaded by default
|
|
55
|
-
// but removing it would break yargs parsing for older projects,
|
|
56
|
-
// so leaving it here so that yargs doesn't throw an error
|
|
57
|
-
loadEnvFiles: {
|
|
58
|
-
hidden: true
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async function handler(options) {
|
|
63
|
-
const { handler: handler2 } = await import("./apiCLIConfigHandler.js");
|
|
64
|
-
await handler2(options);
|
|
65
|
-
}
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
builder,
|
|
69
|
-
description,
|
|
70
|
-
handler
|
|
71
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiCLIConfigHandler.d.ts","sourceRoot":"","sources":["../../src/apiCLIConfigHandler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,wBAAsB,OAAO,CAAC,OAAO,GAAE,gBAAqB,iBAoC3D"}
|