@certik/serverless-api 1.0.6 → 1.0.8
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/CHANGELOG.md +8 -0
- package/lib/app.js +0 -6
- package/lib/cors.js +3 -3
- package/lib/pack.js +1 -1
- package/lib/routes.js +10 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/lib/app.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as pulumi from "@pulumi/pulumi";
|
|
|
2
2
|
import * as aws from "@pulumi/aws";
|
|
3
3
|
import * as apigateway from "@pulumi/aws-apigateway";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
-
import { corsPreflight } from "./cors.js";
|
|
6
5
|
import { isReservedEnvName } from "./env.js";
|
|
7
6
|
import { packAndZip } from "./pack.js";
|
|
8
7
|
|
|
@@ -41,11 +40,6 @@ export async function createPulumiAPIApp({
|
|
|
41
40
|
const wildcardCertificateName = getWildcardCertificateName(domainName);
|
|
42
41
|
const lambdaRoleName = config.get("lambdaRole");
|
|
43
42
|
|
|
44
|
-
// any route that has corsOrigin will have a preflight request
|
|
45
|
-
if (routes.some((r) => r.corsOrigin)) {
|
|
46
|
-
routes.push(corsPreflight());
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
const role = aws.iam.getRole({ name: lambdaRoleName });
|
|
50
44
|
|
|
51
45
|
const sourceBucket = aws.s3.getBucket({ bucket: sourceBucketName });
|
package/lib/cors.js
CHANGED
package/lib/pack.js
CHANGED
|
@@ -11,7 +11,7 @@ const mkdirPromise = promisify(fsModule.mkdir);
|
|
|
11
11
|
const readdirPromise = promisify(fsModule.readdir);
|
|
12
12
|
const cpPromise = promisify(fsModule.cp);
|
|
13
13
|
|
|
14
|
-
const PACK_DIR = ".
|
|
14
|
+
const PACK_DIR = ".serverless-pack";
|
|
15
15
|
const ZIP_FILE = "all-code.zip";
|
|
16
16
|
const EXCLUDED_FILES = [
|
|
17
17
|
"node_modules",
|
package/lib/routes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import pathModule from "node:path";
|
|
2
2
|
import { readdir } from "node:fs/promises";
|
|
3
|
+
import { corsPreflight } from "./cors.js";
|
|
3
4
|
import { DEFAULT_TIMEOUT, MAX_TIMEOUT, DEFAULT_MEMORY_SIZE } from "./const.js";
|
|
4
5
|
|
|
5
6
|
export async function getRoutes(routeDirectory) {
|
|
@@ -13,7 +14,7 @@ export async function getRoutes(routeDirectory) {
|
|
|
13
14
|
const methods = route.methods || ["GET"];
|
|
14
15
|
const environmentVariables = route.environmentVariables || [];
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
const methodRoutes = methods.map((method) => ({
|
|
17
18
|
name: `${routeName}-${method}`,
|
|
18
19
|
path: `/${routeName}`,
|
|
19
20
|
method,
|
|
@@ -23,6 +24,14 @@ export async function getRoutes(routeDirectory) {
|
|
|
23
24
|
memorySize: route.memorySize || DEFAULT_MEMORY_SIZE,
|
|
24
25
|
environmentVariables,
|
|
25
26
|
}));
|
|
27
|
+
|
|
28
|
+
if (route.corsOrigin) {
|
|
29
|
+
methodRoutes.push(
|
|
30
|
+
corsPreflight(`${routeName}-OPTIONS`, `/${routeName}`),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return methodRoutes;
|
|
26
35
|
}),
|
|
27
36
|
);
|
|
28
37
|
|