@mbc-cqrs-serverless/cli 1.4.0 → 1.6.0

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 CHANGED
@@ -18,6 +18,8 @@ A command-line interface for the MBC CQRS Serverless framework. Quickly scaffold
18
18
 
19
19
  ## Installation
20
20
 
21
+ Requires Node.js 22.23.4 or later (`engines.node: ">=22"` since v1.6.0). Projects created by `mbc new` also target Node.js 22 (Lambda `nodejs22.x`, Docker `node:22-bookworm-slim`).
22
+
21
23
  ### Global Installation (Recommended)
22
24
 
23
25
  ```bash
@@ -268,7 +270,7 @@ cp .env.example .env
268
270
  ### 3. Start Local Infrastructure
269
271
 
270
272
  ```bash
271
- # Start Docker services (DynamoDB Local, LocalStack, etc.)
273
+ # Start Docker services (DynamoDB Local, Floci, etc.)
272
274
  npm run offline:docker
273
275
  ```
274
276
 
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = require("fs");
7
+ const path_1 = __importDefault(require("path"));
8
+ // Minimal semver range check for the forms used in overrides: an exact
9
+ // version ("4.3.2"), a bare major selector ("1"), "^x.y.z" (x >= 1) and
10
+ // "~x.y.z". Anything else (prerelease versions, "^1", 0.x caret ranges)
11
+ // throws, so a new form fails the test loudly instead of being misjudged.
12
+ function satisfies(version, range) {
13
+ if (!/^\d+\.\d+\.\d+$/.test(version)) {
14
+ throw new Error(`unsupported version "${version}"`);
15
+ }
16
+ const [major, minor, patch] = version.split('.').map(Number);
17
+ const match = range.match(/^([\^~]?)(\d+)(?:\.(\d+)\.(\d+))?$/);
18
+ if (!match)
19
+ throw new Error(`unsupported range "${range}"`);
20
+ const [, op, maj, min, pat] = match;
21
+ if (min === undefined) {
22
+ if (op !== '')
23
+ throw new Error(`unsupported range "${range}"`);
24
+ return major === Number(maj);
25
+ }
26
+ const [rMajor, rMinor, rPatch] = [Number(maj), Number(min), Number(pat)];
27
+ const atLeast = major > rMajor ||
28
+ (major === rMajor &&
29
+ (minor > rMinor || (minor === rMinor && patch >= rPatch)));
30
+ if (op === '')
31
+ return major === rMajor && minor === rMinor && patch === rPatch;
32
+ if (op === '~')
33
+ return atLeast && major === rMajor && minor === rMinor;
34
+ if (rMajor === 0)
35
+ throw new Error(`unsupported range "${range}"`);
36
+ return atLeast && major === rMajor;
37
+ }
38
+ // `mbc new` copies packages/cli/templates and runs `npm i` plus
39
+ // `npm run migrate` against it, but CI never installs the template. These
40
+ // checks catch template mistakes that only surface in a freshly scaffolded
41
+ // project.
42
+ describe('scaffolding template integrity', () => {
43
+ const templatesDir = path_1.default.join(__dirname, '../../templates');
44
+ describe('package.json overrides', () => {
45
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(templatesDir, 'package.json'), 'utf-8'));
46
+ const directDeps = {
47
+ ...packageJson.dependencies,
48
+ ...packageJson.devDependencies,
49
+ };
50
+ // npm rejects the whole install with EOVERRIDE ("Override for X conflicts
51
+ // with direct dependency") when an override of a direct dependency does
52
+ // not match its spec exactly. Use "$X" to reference the direct spec.
53
+ it.each(Object.entries(packageJson.overrides ?? {}).filter(([name]) => name in directDeps))('override for direct dependency %s matches its spec', (name, override) => {
54
+ const spec = typeof override === 'string'
55
+ ? override
56
+ : override['.'];
57
+ if (spec === undefined)
58
+ return;
59
+ expect([directDeps[name], `$${name}`]).toContain(spec);
60
+ });
61
+ // The root overrides that clear production advisories do not reach
62
+ // scaffolded projects: `mbc new` copies the template with its own
63
+ // package.json and lockfile. Every root override whose package ships in
64
+ // the template's production tree must therefore be mirrored in the
65
+ // template, so new projects do not keep advisories the CHANGELOG reports
66
+ // as fixed. Root overrides for packages that the template only has as dev
67
+ // dependencies (or not at all) are not required.
68
+ const rootOverrides = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(templatesDir, '../../../package.json'), 'utf-8')).overrides;
69
+ const lockPackages = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(templatesDir, 'package-lock.json'), 'utf-8')).packages;
70
+ const productionPackages = new Set(Object.entries(lockPackages)
71
+ .filter(([key, entry]) => key.includes('node_modules/') && !entry.dev && !entry.devOptional)
72
+ .map(([key]) => key.slice(key.lastIndexOf('node_modules/') + 13)));
73
+ // "body-parser@1" -> "body-parser", "@scope/name@2" -> "@scope/name"
74
+ const packageName = (selector) => {
75
+ const at = selector.lastIndexOf('@');
76
+ return at > 0 ? selector.slice(0, at) : selector;
77
+ };
78
+ const mirrored = Object.keys(rootOverrides).filter((selector) => productionPackages.has(packageName(selector)));
79
+ it('finds the production overrides to mirror', () => {
80
+ expect(mirrored).toEqual(expect.arrayContaining([
81
+ 'multer',
82
+ 'proxy-addr',
83
+ 'body-parser@1',
84
+ 'body-parser@2',
85
+ 'qs',
86
+ ]));
87
+ });
88
+ it.each(mirrored)('mirrors the root override for %s', (selector) => {
89
+ const name = packageName(selector);
90
+ const override = packageJson.overrides?.[selector];
91
+ // A direct dependency must be overridden with "$name" (EOVERRIDE); the
92
+ // lockfile check below still holds its resolved version to the root.
93
+ if (name in directDeps && override === `$${name}`)
94
+ return;
95
+ expect(override).toEqual(rootOverrides[selector]);
96
+ });
97
+ // The override strings can match while the committed lockfile, which is
98
+ // what `mbc new` installs from, still pins an older version. Every
99
+ // production copy of a mirrored package must satisfy the root range.
100
+ it.each(mirrored.filter((selector) => typeof rootOverrides[selector] === 'string'))('template lockfile satisfies the root override for %s', (selector) => {
101
+ const name = packageName(selector);
102
+ const selectorRange = selector.slice(name.length + 1); // "1" in body-parser@1
103
+ const copies = Object.entries(lockPackages)
104
+ .filter(([key, entry]) => key.endsWith(`node_modules/${name}`) &&
105
+ !entry.dev &&
106
+ !entry.devOptional)
107
+ .map(([, entry]) => entry.version)
108
+ .filter((version) => !selectorRange || satisfies(version, selectorRange));
109
+ // A version-scoped selector (body-parser@2) may match no copy in the
110
+ // template; an unscoped one always does, since it is in production.
111
+ if (!selectorRange)
112
+ expect(copies.length).toBeGreaterThan(0);
113
+ for (const version of copies) {
114
+ expect({
115
+ version,
116
+ satisfies: satisfies(version, rootOverrides[selector]),
117
+ }).toEqual({ version, satisfies: true });
118
+ }
119
+ });
120
+ });
121
+ describe('prisma/ddb.ts (npm run migrate:ddb)', () => {
122
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(templatesDir, 'package.json'), 'utf-8'));
123
+ const source = (0, fs_1.readFileSync)(path_1.default.join(templatesDir, 'prisma/ddb.ts'), 'utf-8');
124
+ // .env.local writes endpoints as http://localhost:${LOCAL_X_PORT:-NNNN};
125
+ // plain dotenv leaves that literal and the DynamoDB client throws
126
+ // "Invalid URL", so the loaded env must go through dotenv-expand.
127
+ it('expands ${VAR:-default} when loading .env', () => {
128
+ expect(source).toMatch(/expand\(\s*dotenv\.config\(/);
129
+ });
130
+ it('declares dotenv and dotenv-expand as direct dependencies', () => {
131
+ const deps = {
132
+ ...packageJson.dependencies,
133
+ ...packageJson.devDependencies,
134
+ };
135
+ expect(deps).toHaveProperty('dotenv');
136
+ expect(deps).toHaveProperty('dotenv-expand');
137
+ });
138
+ });
139
+ describe('.env.local DATABASE_URL', () => {
140
+ const lines = (0, fs_1.readFileSync)(path_1.default.join(templatesDir, '.env.local'), 'utf-8').split('\n');
141
+ const index = lines.findIndex((line) => line.startsWith('DATABASE_URL='));
142
+ const databaseUrl = lines[index];
143
+ it('is defined', () => {
144
+ expect(index).toBeGreaterThanOrEqual(0);
145
+ });
146
+ // Prisma expands ${VAR} in .env but not ${VAR:-default}; the latter fails
147
+ // `prisma migrate deploy` with P1013 "invalid port number".
148
+ it('does not use ${VAR:-default} expansion', () => {
149
+ expect(databaseUrl).not.toMatch(/\$\{[A-Z0-9_]+:-/);
150
+ });
151
+ it('only references variables defined earlier in the file', () => {
152
+ const referenced = [...databaseUrl.matchAll(/\$\{([A-Z0-9_]+)\}/g)].map((match) => match[1]);
153
+ const definedBefore = lines
154
+ .slice(0, index)
155
+ .map((line) => line.match(/^([A-Z0-9_]+)=/)?.[1])
156
+ .filter(Boolean);
157
+ for (const name of referenced) {
158
+ expect(definedBefore).toContain(name);
159
+ }
160
+ });
161
+ });
162
+ });
@@ -5,41 +5,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const faker_1 = require("@faker-js/faker");
7
7
  const fs_1 = require("fs");
8
+ const os_1 = require("os");
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const new_action_1 = require("./new.action");
10
11
  const { usePackageVersion } = new_action_1.exportsForTesting;
11
12
  // create testcase for usePackageVersion function in new.action.ts file
12
13
  describe('usePackageVersion', () => {
13
- const fname = path_1.default.join(__dirname, 'package.json');
14
+ // Work on a copy in a temporary directory. Writing package.json next to the
15
+ // sources (src/actions) races with other suites resolving './new.action'
16
+ // in parallel Jest workers and fails them with "Cannot find module".
17
+ let destDir;
18
+ let fname;
14
19
  const packageVersion = '1.0.0';
15
20
  const packageJson = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '../../package.json')).toString());
16
21
  beforeEach(() => {
22
+ destDir = (0, fs_1.mkdtempSync)(path_1.default.join((0, os_1.tmpdir)(), 'mbc-use-package-version-'));
23
+ fname = path_1.default.join(destDir, 'package.json');
17
24
  (0, fs_1.copyFileSync)(path_1.default.join(__dirname, '../../templates/package.json'), fname);
18
25
  });
19
26
  afterEach(() => {
20
- (0, fs_1.unlinkSync)(fname);
27
+ (0, fs_1.rmSync)(destDir, { recursive: true, force: true });
21
28
  });
22
29
  it('it should update deps', () => {
23
- usePackageVersion(__dirname, packageVersion);
30
+ usePackageVersion(destDir, packageVersion);
24
31
  const tplPackageJson = JSON.parse((0, fs_1.readFileSync)(fname).toString());
25
32
  expect(tplPackageJson.dependencies['@mbc-cqrs-serverless/core']).toBe(packageVersion);
26
33
  expect(packageJson.version).toBe(tplPackageJson.devDependencies['@mbc-cqrs-serverless/cli']);
27
34
  });
28
35
  it('it should not update name', () => {
29
36
  const { name } = JSON.parse((0, fs_1.readFileSync)(fname).toString());
30
- usePackageVersion(__dirname, packageVersion);
37
+ usePackageVersion(destDir, packageVersion);
31
38
  const tplPackageJson = JSON.parse((0, fs_1.readFileSync)(fname).toString());
32
39
  expect(name).toBe(tplPackageJson.name);
33
40
  });
34
41
  it('it should not update name with empty name', () => {
35
42
  const { name } = JSON.parse((0, fs_1.readFileSync)(fname).toString());
36
- usePackageVersion(__dirname, packageVersion, '');
43
+ usePackageVersion(destDir, packageVersion, '');
37
44
  const tplPackageJson = JSON.parse((0, fs_1.readFileSync)(fname).toString());
38
45
  expect(name).toBe(tplPackageJson.name);
39
46
  });
40
47
  it('it should update name', () => {
41
48
  const name = faker_1.faker.word.sample();
42
- usePackageVersion(__dirname, packageVersion, name);
49
+ usePackageVersion(destDir, packageVersion, name);
43
50
  const tplPackageJson = JSON.parse((0, fs_1.readFileSync)(fname).toString());
44
51
  expect(name).toBe(tplPackageJson.name);
45
52
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbc-cqrs-serverless/cli",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "a CLI to get started with MBC CQRS serverless framework",
5
5
  "keywords": [
6
6
  "mbc",
@@ -58,5 +58,8 @@
58
58
  "@faker-js/faker": "^8.3.1",
59
59
  "copyfiles": "^2.4.1"
60
60
  },
61
- "gitHead": "972a2726e2696e94e988dfc3135086b13cf2345b"
61
+ "engines": {
62
+ "node": ">=22"
63
+ },
64
+ "gitHead": "cca6876ffeb3fe44b553f972bacfd36af7269d4c"
62
65
  }
@@ -26,7 +26,7 @@ LOCAL_OFFLINE_LAMBDA_PORT=4000
26
26
  LOCAL_DYNAMODB_PORT=8000
27
27
  # MySQL (RDS)
28
28
  LOCAL_RDS_PORT=3306
29
- # LocalStack (S3)
29
+ # Floci (S3)
30
30
  LOCAL_S3_PORT=4566
31
31
  # SNS
32
32
  LOCAL_SNS_PORT=4002
@@ -93,7 +93,7 @@ SES_FROM_EMAIL=email@example.com
93
93
  # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
94
94
  # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
95
95
 
96
- DATABASE_URL="mysql://root:RootCqrs@localhost:${LOCAL_RDS_PORT:-3306}/cqrs?schema=public&connection_limit=1"
96
+ DATABASE_URL="mysql://root:RootCqrs@localhost:${LOCAL_RDS_PORT}/cqrs?schema=public&connection_limit=1"
97
97
 
98
98
  # serverless dynamodb local stream
99
99
  LOCAL_DDB_SAMPLE_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-test-cli-sample-command/stream/2025-01-14T12:05:57.881
@@ -1,8 +1,11 @@
1
- FROM node:20-bullseye-slim AS builder
1
+ FROM node:22-bookworm-slim AS builder
2
2
 
3
3
  # RUN apk update
4
4
  # RUN apk --no-cache add make gcc g++ --virtual .builds-deps build-base python3 musl-dev openssl-dev
5
5
 
6
+ # Prisma's query engine needs libssl, which bookworm-slim does not ship
7
+ RUN apt-get update -y && apt-get install -y --no-install-recommends openssl && rm -rf /var/lib/apt/lists/*
8
+
6
9
  WORKDIR /app
7
10
 
8
11
  COPY package*.json ./
@@ -14,11 +17,14 @@ COPY . .
14
17
 
15
18
  RUN npm run build:prod
16
19
 
17
- FROM node:20-bullseye-slim
20
+ FROM node:22-bookworm-slim
18
21
 
19
22
  # RUN apk update
20
23
  # RUN apk --no-cache add make gcc g++ --virtual .builds-deps build-base python3 musl-dev openssl-dev
21
24
 
25
+ # Prisma's query engine needs libssl, which bookworm-slim does not ship
26
+ RUN apt-get update -y && apt-get install -y --no-install-recommends openssl && rm -rf /var/lib/apt/lists/*
27
+
22
28
  WORKDIR /app
23
29
 
24
30
  COPY --from=builder /app/package*.json ./
@@ -17,7 +17,7 @@ TechStack:
17
17
  - DynamoDB
18
18
 
19
19
  - RDS - PostgreSQL
20
- - Serverless fw && Localstack for local development
20
+ - Serverless fw && Floci for local development
21
21
 
22
22
  ## Prepare
23
23
 
@@ -147,8 +147,7 @@ $ aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state
147
147
  - sns: http://localhost:4002
148
148
  - sqs: http://localhost:9324
149
149
  - sqs admin: http://localhost:9325
150
- - localstack: http://localhost:4566
151
- - S3
150
+ - floci (S3): http://localhost:4566
152
151
  - appsync: http://localhost:4001
153
152
  - cognito: http://localhost:9229
154
153
  - eventbridge: http://localhost:4010
@@ -414,7 +414,7 @@ export class InfraStack extends cdk.Stack {
414
414
  const lambdaLayer = new cdk.aws_lambda.LayerVersion(this, 'main-layer', {
415
415
  layerVersionName: prefix + 'main-layer',
416
416
  code: cdk.aws_lambda.AssetCode.fromAsset(layerPath),
417
- compatibleRuntimes: [cdk.aws_lambda.Runtime.NODEJS_20_X],
417
+ compatibleRuntimes: [cdk.aws_lambda.Runtime.NODEJS_22_X],
418
418
  compatibleArchitectures: [cdk.aws_lambda.Architecture.ARM_64],
419
419
  })
420
420
 
@@ -500,7 +500,7 @@ export class InfraStack extends cdk.Stack {
500
500
  layers: [lambdaLayer],
501
501
  code: cdk.aws_lambda.Code.fromAsset(appPath),
502
502
  handler: 'main.handler',
503
- runtime: cdk.aws_lambda.Runtime.NODEJS_20_X,
503
+ runtime: cdk.aws_lambda.Runtime.NODEJS_22_X,
504
504
  timeout: cdk.Duration.seconds(30),
505
505
  memorySize: 512,
506
506
  tracing: cdk.aws_lambda.Tracing.ACTIVE,
@@ -73,6 +73,20 @@ export class PipelineStack extends Stack {
73
73
 
74
74
  const pipeline = new CodePipeline(this, idName + 'PipelineV3', {
75
75
  selfMutation: true,
76
+ // Build, test and synthesize on Node.js 22 to match the nodejs22.x
77
+ // Lambda runtime and the framework's engines (>=22). Without this the
78
+ // CodeBuild image's default Node.js version is used, which can change.
79
+ codeBuildDefaults: {
80
+ partialBuildSpec: BuildSpec.fromObject({
81
+ phases: {
82
+ install: {
83
+ 'runtime-versions': {
84
+ nodejs: '22',
85
+ },
86
+ },
87
+ },
88
+ }),
89
+ },
76
90
  synth: new ShellStep('Synth', {
77
91
  input: CodePipelineSource.connection(GIT_REPO, branchName, {
78
92
  connectionArn: GIT_CONNECTION_ARN,
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "@types/jest": "^29.5.10",
15
- "@types/node": "^20.9.4",
15
+ "@types/node": "^22.20.5",
16
16
  "aws-cdk": "^2.147.0",
17
17
  "jest": "^29.7.0",
18
18
  "jest-junit": "^16.0.0",
@@ -405,6 +405,25 @@ exports[`snapshot test for InfraStack 1`] = `
405
405
  "Statement": [
406
406
  {
407
407
  "Action": "sts:AssumeRole",
408
+ "Condition": {
409
+ "ArnLike": {
410
+ "aws:SourceArn": {
411
+ "Fn::Join": [
412
+ "",
413
+ [
414
+ "arn:",
415
+ {
416
+ "Ref": "AWS::Partition",
417
+ },
418
+ ":states:ap-northeast-1:101010101010:stateMachine:*",
419
+ ],
420
+ ],
421
+ },
422
+ },
423
+ "StringEquals": {
424
+ "aws:SourceAccount": "101010101010",
425
+ },
426
+ },
408
427
  "Effect": "Allow",
409
428
  "Principal": {
410
429
  "Service": "states.amazonaws.com",
@@ -931,6 +950,25 @@ exports[`snapshot test for InfraStack 1`] = `
931
950
  "Statement": [
932
951
  {
933
952
  "Action": "sts:AssumeRole",
953
+ "Condition": {
954
+ "ArnLike": {
955
+ "aws:SourceArn": {
956
+ "Fn::Join": [
957
+ "",
958
+ [
959
+ "arn:",
960
+ {
961
+ "Ref": "AWS::Partition",
962
+ },
963
+ ":states:ap-northeast-1:101010101010:stateMachine:*",
964
+ ],
965
+ ],
966
+ },
967
+ },
968
+ "StringEquals": {
969
+ "aws:SourceAccount": "101010101010",
970
+ },
971
+ },
934
972
  "Effect": "Allow",
935
973
  "Principal": {
936
974
  "Service": "states.amazonaws.com",
@@ -1160,7 +1198,7 @@ exports[`snapshot test for InfraStack 1`] = `
1160
1198
  "Arn",
1161
1199
  ],
1162
1200
  },
1163
- "Runtime": "nodejs20.x",
1201
+ "Runtime": "nodejs22.x",
1164
1202
  "Tags": [
1165
1203
  {
1166
1204
  "Key": "env",
@@ -2443,7 +2481,7 @@ exports[`snapshot test for InfraStack 1`] = `
2443
2481
  "arm64",
2444
2482
  ],
2445
2483
  "CompatibleRuntimes": [
2446
- "nodejs20.x",
2484
+ "nodejs22.x",
2447
2485
  ],
2448
2486
  "Content": {
2449
2487
  "S3Bucket": "cdk-hnb659fds-assets-101010101010-ap-northeast-1",
@@ -3153,6 +3191,25 @@ schema {
3153
3191
  "Statement": [
3154
3192
  {
3155
3193
  "Action": "sts:AssumeRole",
3194
+ "Condition": {
3195
+ "ArnLike": {
3196
+ "aws:SourceArn": {
3197
+ "Fn::Join": [
3198
+ "",
3199
+ [
3200
+ "arn:",
3201
+ {
3202
+ "Ref": "AWS::Partition",
3203
+ },
3204
+ ":states:ap-northeast-1:101010101010:stateMachine:*",
3205
+ ],
3206
+ ],
3207
+ },
3208
+ },
3209
+ "StringEquals": {
3210
+ "aws:SourceAccount": "101010101010",
3211
+ },
3212
+ },
3156
3213
  "Effect": "Allow",
3157
3214
  "Principal": {
3158
3215
  "Service": "states.amazonaws.com",
@@ -6,10 +6,11 @@ import * as cdk from 'aws-cdk-lib'
6
6
  import { Match, Template } from 'aws-cdk-lib/assertions'
7
7
  import { getConfig } from '../config'
8
8
  import { InfraStack } from '../libs/infra-stack'
9
+ import { PipelineStack } from '../libs/pipeline-stack'
9
10
 
10
11
  jest.mock('../config/constant', () => ({
11
12
  PIPELINE_NAME: 'test-pipeline',
12
- GIT_REPO: 'test-repo',
13
+ GIT_REPO: 'test-owner/test-repo',
13
14
  GIT_CONNECTION_ARN:
14
15
  'arn:aws:codestar-connections:ap-northeast-1:101010101010:connection/test',
15
16
  ACM_HTTP_CERTIFICATE_ARN:
@@ -132,3 +133,37 @@ test('lambda-api SendTaskSuccess is scoped to command-handler state machine', ()
132
133
  },
133
134
  })
134
135
  })
136
+
137
+ test('pipeline CodeBuild projects pin the Node.js 22 runtime', () => {
138
+ // The Lambda functions and layer run on nodejs22.x and every package
139
+ // requires Node.js >=22, so tests, synth and the layer build must not
140
+ // depend on the CodeBuild image's default Node.js version.
141
+ const app = new cdk.App()
142
+ const stack = new PipelineStack(app, 'TestPipelineStack', {
143
+ env: { account: '101010101010', region: 'ap-northeast-1' },
144
+ envName: 'dev',
145
+ })
146
+ const projects = Template.fromStack(stack).findResources(
147
+ 'AWS::CodeBuild::Project',
148
+ )
149
+
150
+ expect(Object.keys(projects).length).toBeGreaterThan(0)
151
+ // A buildspec that embeds CloudFormation references is an Fn::Join; render
152
+ // the references as placeholder text so the JSON can be parsed.
153
+ const render = (value: any): string =>
154
+ typeof value === 'string'
155
+ ? value
156
+ : value?.['Fn::Join']
157
+ ? value['Fn::Join'][1].map(render).join(value['Fn::Join'][0])
158
+ : 'TOKEN'
159
+ for (const project of Object.values(projects)) {
160
+ const source = project.Properties.Source.BuildSpec
161
+ // Only a plain string or an Fn::Join renders to parseable JSON; fail with
162
+ // a clear message if a CDK upgrade emits another form (e.g. Fn::Sub).
163
+ expect(typeof source === 'string' || 'Fn::Join' in source).toBe(true)
164
+ const buildSpec = JSON.parse(render(source))
165
+ expect(buildSpec.phases?.install?.['runtime-versions']).toEqual({
166
+ nodejs: '22',
167
+ })
168
+ }
169
+ })
@@ -1,4 +1,4 @@
1
- FROM node:18-alpine
1
+ FROM node:22-alpine
2
2
  WORKDIR /app
3
3
 
4
4
  COPY ./package.json ./
@@ -1,4 +1,4 @@
1
- FROM node:18-alpine
1
+ FROM node:22-alpine
2
2
  WORKDIR /app
3
3
 
4
4
  COPY ./package.json ./
@@ -56,19 +56,15 @@ services:
56
56
  - ./elasticmq.conf:/opt/elasticmq.conf
57
57
  - ./docker-data/elasticmq:/data
58
58
 
59
- localstack:
60
- image: localstack/localstack
59
+ floci:
60
+ image: floci/floci:1.6.0
61
61
  ports:
62
62
  - '${LOCAL_S3_PORT:-4566}:4566'
63
63
  environment:
64
- - SERVICES=s3
65
- - AWS_DEFAULT_REGION=ap-northeast-1
66
- - SERVICE_ACCESS_KEY=local
67
- - SERVICE_SECRET_KEY=local
68
- - EXTRA_CORS_ALLOWED_ORIGINS=*
64
+ - FLOCI_DEFAULT_REGION=ap-northeast-1
65
+ - FLOCI_STORAGE_MODE=persistent
69
66
  volumes:
70
- - ./docker-data/localstack:/var/lib/localstack
71
- - ./docker-data/run/docker.sock:/var/run/docker.sock
67
+ - floci-data:/app/data
72
68
 
73
69
  appsync:
74
70
  build:
@@ -93,3 +89,6 @@ services:
93
89
  - ${LOCAL_COGNITO_PORT:-9229}:${LOCAL_COGNITO_PORT:-9229}
94
90
  volumes:
95
91
  - ./docker-data/.cognito:/app/.cognito
92
+
93
+ volumes:
94
+ floci-data:
@@ -24,5 +24,49 @@ if (-not $bucketExists) {
24
24
  Write-Host "Bucket $env:S3_BUCKET_NAME already exists."
25
25
  }
26
26
 
27
+ # Presigned upload/view URLs (see DirectoryFileService) are fetched by the
28
+ # browser, so the bucket needs a CORS rule or the preflight fails with 403 and
29
+ # the real request is never sent. The previous LocalStack service granted this
30
+ # implicitly through EXTRA_CORS_ALLOWED_ORIGINS=*, which Floci 1.6.0 does not
31
+ # honor (its global switch is FLOCI_SECURITY_EXTRA_CORS_ALLOWED_ORIGINS); a bucket
32
+ # rule is used instead so local matches production.
33
+ # Production configures CORS in the CDK stack - this is the local equivalent.
34
+ # Applied unconditionally so buckets created before this script gained the rule
35
+ # are brought up to date too.
36
+ Write-Host "======= configure S3 bucket CORS ======="
37
+ $corsConfiguration = @'
38
+ {
39
+ "CORSRules": [
40
+ {
41
+ "AllowedOrigins": ["*"],
42
+ "AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
43
+ "AllowedHeaders": ["*"],
44
+ "ExposeHeaders": ["ETag"]
45
+ }
46
+ ]
47
+ }
48
+ '@
49
+
50
+ # Passed as file:// rather than inline: PowerShell mangles embedded quotes on
51
+ # the way to the AWS CLI.
52
+ $corsFile = Join-Path ([System.IO.Path]::GetTempPath()) "mbc-s3-cors.json"
53
+ # Written BOM-less on purpose. Windows PowerShell 5.1 - still the default
54
+ # powershell.exe - writes a BOM for "-Encoding utf8", and the AWS CLI rejects
55
+ # the file with "Error parsing parameter '--cors-configuration'" before it
56
+ # sends any request, so the rule silently never lands. PowerShell 7 writes no
57
+ # BOM, which is why this only fails on stock Windows. WriteAllText behaves the
58
+ # same on both.
59
+ [System.IO.File]::WriteAllText($corsFile, $corsConfiguration, (New-Object System.Text.UTF8Encoding $false))
60
+ try {
61
+ aws --endpoint-url=http://localhost:$s3Port s3api put-bucket-cors --bucket $env:S3_BUCKET_NAME --cors-configuration "file://$corsFile"
62
+ # aws exits non-zero on both a rejected --cors-configuration (252) and an
63
+ # unreachable endpoint (255), but PowerShell does not throw on native
64
+ # command failure, so without this the rule can silently never land and the
65
+ # script still exits 0.
66
+ if ($LASTEXITCODE -ne 0) { throw "put-bucket-cors failed ($LASTEXITCODE)" }
67
+ } finally {
68
+ Remove-Item $corsFile -ErrorAction SilentlyContinue
69
+ }
70
+
27
71
  Write-Host "======= list S3 buckets ======="
28
72
  aws --endpoint-url=http://localhost:$s3Port s3 ls
@@ -19,5 +19,28 @@ else
19
19
  echo "Bucket $S3_BUCKET_NAME already exists."
20
20
  fi
21
21
 
22
+ # Presigned upload/view URLs (see DirectoryFileService) are fetched by the
23
+ # browser, so the bucket needs a CORS rule or the preflight fails with 403 and
24
+ # the real request is never sent. The previous LocalStack service granted this
25
+ # implicitly through EXTRA_CORS_ALLOWED_ORIGINS=*, which Floci 1.6.0 does not
26
+ # honor (its global switch is FLOCI_SECURITY_EXTRA_CORS_ALLOWED_ORIGINS); a bucket
27
+ # rule is used instead so local matches production.
28
+ # Production configures CORS in the CDK stack — this is the local equivalent.
29
+ # Applied unconditionally so buckets created before this script gained the rule
30
+ # are brought up to date too.
31
+ echo "======= configure S3 bucket CORS ======="
32
+ aws --endpoint-url=${S3_ENDPOINT_URL} s3api put-bucket-cors \
33
+ --bucket $S3_BUCKET_NAME \
34
+ --cors-configuration '{
35
+ "CORSRules": [
36
+ {
37
+ "AllowedOrigins": ["*"],
38
+ "AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
39
+ "AllowedHeaders": ["*"],
40
+ "ExposeHeaders": ["ETag"]
41
+ }
42
+ ]
43
+ }'
44
+
22
45
  echo "======= list S3 buckets ======="
23
46
  aws --endpoint-url=${S3_ENDPOINT_URL} s3 ls
@@ -119,13 +119,11 @@ custom:
119
119
  retryDelayMs: 500 # retry delay
120
120
  throwRetryExhausted: false # default true
121
121
  payloadSizeLimit: '10mb' # Controls the maximum payload size being passed to https://www.npmjs.com/package/bytes (Note: this payload size might not be the same size as your AWS Eventbridge receive)
122
- # localStackConfig:
123
- # localStackEndpoint: http://localhost:4566
124
122
 
125
123
  provider:
126
124
  name: aws
127
125
  region: ap-northeast-1
128
- runtime: nodejs18.x
126
+ runtime: nodejs22.x
129
127
  profile: serverless
130
128
  timeout: 100
131
129
  httpApi:
@@ -26,7 +26,7 @@
26
26
  "@types/aws-lambda": "^8.10.130",
27
27
  "@types/express": "^4.17.21",
28
28
  "@types/jest": "^29.5.11",
29
- "@types/node": "^20.10.5",
29
+ "@types/node": "^22.20.5",
30
30
  "@types/node-fetch": "^2.6.9",
31
31
  "@types/supertest": "^6.0.1",
32
32
  "@typescript-eslint/eslint-plugin": "^8.61.0",
@@ -34,6 +34,8 @@
34
34
  "class-transformer": "^0.5.1",
35
35
  "class-validator": "^0.14.0",
36
36
  "concurrently": "^9.0.1",
37
+ "dotenv": "^16.4.5",
38
+ "dotenv-expand": "^10.0.0",
37
39
  "eslint": "^8.56.0",
38
40
  "eslint-config-prettier": "^9.1.0",
39
41
  "eslint-plugin-import": "^2.29.1",
@@ -41,13 +43,13 @@
41
43
  "eslint-plugin-simple-import-sort": "^10.0.0",
42
44
  "jest": "^29.7.0",
43
45
  "jest-junit": "^16.0.0",
46
+ "js-yaml": "^4.3.2",
44
47
  "nestjs-spelunker": "^1.3.0",
45
48
  "prettier": "^3.1.1",
46
49
  "run-script-os": "^1.1.6",
47
50
  "serverless": "^3.40.0",
48
51
  "serverless-dynamodb": "^0.2.47",
49
- "serverless-localstack": "^1.1.2",
50
- "serverless-offline": "^13.3.2",
52
+ "serverless-offline": "^13.9.0",
51
53
  "serverless-offline-aws-eventbridge": "^2.1.0",
52
54
  "serverless-offline-dynamodb-streams": "^7.0.0",
53
55
  "serverless-offline-lambda": "^1.0.6",
@@ -73,6 +75,9 @@
73
75
  "ulid": "^2.3.0",
74
76
  "webpack": "^5.105.0"
75
77
  },
78
+ "engines": {
79
+ "node": ">=22"
80
+ },
76
81
  "optionalDependencies": {
77
82
  "@aws-sdk/client-dynamodb": "^3.981.0",
78
83
  "@aws-sdk/client-s3": "^3.981.0",
@@ -265,6 +270,23 @@
265
270
  }
266
271
  }
267
272
  },
273
+ "node_modules/@angular-devkit/schematics-cli/node_modules/chokidar": {
274
+ "version": "4.0.3",
275
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
276
+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
277
+ "dev": true,
278
+ "optional": true,
279
+ "peer": true,
280
+ "dependencies": {
281
+ "readdirp": "^4.0.1"
282
+ },
283
+ "engines": {
284
+ "node": ">= 14.16.0"
285
+ },
286
+ "funding": {
287
+ "url": "https://paulmillr.com/funding/"
288
+ }
289
+ },
268
290
  "node_modules/@angular-devkit/schematics-cli/node_modules/jsonc-parser": {
269
291
  "version": "3.3.1",
270
292
  "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz",
@@ -282,6 +304,21 @@
282
304
  "@jridgewell/sourcemap-codec": "^1.5.0"
283
305
  }
284
306
  },
307
+ "node_modules/@angular-devkit/schematics-cli/node_modules/readdirp": {
308
+ "version": "4.1.2",
309
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
310
+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
311
+ "dev": true,
312
+ "optional": true,
313
+ "peer": true,
314
+ "engines": {
315
+ "node": ">= 14.18.0"
316
+ },
317
+ "funding": {
318
+ "type": "individual",
319
+ "url": "https://paulmillr.com/funding/"
320
+ }
321
+ },
285
322
  "node_modules/@aws-crypto/crc32": {
286
323
  "version": "5.2.0",
287
324
  "resolved": "https://registry.npmjs.org/@aws-crypto/crc32/-/crc32-5.2.0.tgz",
@@ -13611,12 +13648,13 @@
13611
13648
  "dev": true
13612
13649
  },
13613
13650
  "node_modules/@types/node": {
13614
- "version": "20.16.10",
13615
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz",
13616
- "integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==",
13651
+ "version": "22.20.5",
13652
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz",
13653
+ "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==",
13617
13654
  "dev": true,
13655
+ "license": "MIT",
13618
13656
  "dependencies": {
13619
- "undici-types": "~6.19.2"
13657
+ "undici-types": "~6.21.0"
13620
13658
  }
13621
13659
  },
13622
13660
  "node_modules/@types/node-fetch": {
@@ -14535,6 +14573,18 @@
14535
14573
  "node": ">= 8"
14536
14574
  }
14537
14575
  },
14576
+ "node_modules/anymatch/node_modules/picomatch": {
14577
+ "version": "2.3.2",
14578
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
14579
+ "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
14580
+ "dev": true,
14581
+ "engines": {
14582
+ "node": ">=8.6"
14583
+ },
14584
+ "funding": {
14585
+ "url": "https://github.com/sponsors/jonschlinkert"
14586
+ }
14587
+ },
14538
14588
  "node_modules/anynum": {
14539
14589
  "version": "1.0.0",
14540
14590
  "resolved": "https://registry.npmjs.org/anynum/-/anynum-1.0.0.tgz",
@@ -15312,9 +15362,9 @@
15312
15362
  "dev": true
15313
15363
  },
15314
15364
  "node_modules/body-parser": {
15315
- "version": "1.20.4",
15316
- "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
15317
- "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
15365
+ "version": "1.20.9",
15366
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz",
15367
+ "integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==",
15318
15368
  "license": "MIT",
15319
15369
  "dependencies": {
15320
15370
  "bytes": "~3.1.2",
@@ -15325,7 +15375,7 @@
15325
15375
  "http-errors": "~2.0.1",
15326
15376
  "iconv-lite": "~0.4.24",
15327
15377
  "on-finished": "~2.4.1",
15328
- "qs": "~6.14.0",
15378
+ "qs": "~6.16.0",
15329
15379
  "raw-body": "~2.5.3",
15330
15380
  "type-is": "~1.6.18",
15331
15381
  "unpipe": "~1.0.0"
@@ -15339,6 +15389,7 @@
15339
15389
  "version": "2.6.9",
15340
15390
  "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
15341
15391
  "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
15392
+ "license": "MIT",
15342
15393
  "dependencies": {
15343
15394
  "ms": "2.0.0"
15344
15395
  }
@@ -15366,7 +15417,8 @@
15366
15417
  "node_modules/body-parser/node_modules/ms": {
15367
15418
  "version": "2.0.0",
15368
15419
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
15369
- "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
15420
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
15421
+ "license": "MIT"
15370
15422
  },
15371
15423
  "node_modules/body-parser/node_modules/statuses": {
15372
15424
  "version": "2.0.2",
@@ -15668,7 +15720,8 @@
15668
15720
  "node_modules/buffer-from": {
15669
15721
  "version": "1.1.2",
15670
15722
  "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
15671
- "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="
15723
+ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
15724
+ "dev": true
15672
15725
  },
15673
15726
  "node_modules/builtin-modules": {
15674
15727
  "version": "3.3.0",
@@ -16524,6 +16577,7 @@
16524
16577
  "version": "2.0.0",
16525
16578
  "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
16526
16579
  "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
16580
+ "dev": true,
16527
16581
  "engines": [
16528
16582
  "node >= 6.0"
16529
16583
  ],
@@ -16539,6 +16593,7 @@
16539
16593
  "version": "3.6.2",
16540
16594
  "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
16541
16595
  "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
16596
+ "dev": true,
16542
16597
  "license": "MIT",
16543
16598
  "dependencies": {
16544
16599
  "inherits": "^2.0.3",
@@ -17970,12 +18025,6 @@
17970
18025
  "es6-symbol": "^3.1.1"
17971
18026
  }
17972
18027
  },
17973
- "node_modules/es6-promisify": {
17974
- "version": "6.1.1",
17975
- "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz",
17976
- "integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg==",
17977
- "dev": true
17978
- },
17979
18028
  "node_modules/es6-set": {
17980
18029
  "version": "0.1.6",
17981
18030
  "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.6.tgz",
@@ -22089,9 +22138,19 @@
22089
22138
  "dev": true
22090
22139
  },
22091
22140
  "node_modules/js-yaml": {
22092
- "version": "4.1.1",
22093
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
22094
- "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
22141
+ "version": "4.3.2",
22142
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz",
22143
+ "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==",
22144
+ "funding": [
22145
+ {
22146
+ "type": "github",
22147
+ "url": "https://github.com/sponsors/puzrin"
22148
+ },
22149
+ {
22150
+ "type": "github",
22151
+ "url": "https://github.com/sponsors/nodeca"
22152
+ }
22153
+ ],
22095
22154
  "license": "MIT",
22096
22155
  "dependencies": {
22097
22156
  "argparse": "^2.0.1"
@@ -23583,14 +23642,13 @@
23583
23642
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
23584
23643
  },
23585
23644
  "node_modules/multer": {
23586
- "version": "2.2.0",
23587
- "resolved": "https://registry.npmjs.org/multer/-/multer-2.2.0.tgz",
23588
- "integrity": "sha512-6rdyFg2kLrMh9Jee7/BMPuV9lEAd7lLW2YUpF9/YxR7njyoUwwQ0ZPh3TaIY50Sw6vlyD2HW3wGOkTS4P79xrQ==",
23645
+ "version": "2.5.0",
23646
+ "resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
23647
+ "integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
23589
23648
  "license": "MIT",
23590
23649
  "dependencies": {
23591
23650
  "append-field": "^1.0.0",
23592
23651
  "busboy": "^1.6.0",
23593
- "concat-stream": "^2.0.0",
23594
23652
  "type-is": "^1.6.18"
23595
23653
  },
23596
23654
  "engines": {
@@ -24855,15 +24913,20 @@
24855
24913
  }
24856
24914
  },
24857
24915
  "node_modules/proxy-addr": {
24858
- "version": "2.0.7",
24859
- "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
24860
- "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
24916
+ "version": "2.0.8",
24917
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
24918
+ "integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
24919
+ "license": "MIT",
24861
24920
  "dependencies": {
24862
24921
  "forwarded": "0.2.0",
24863
24922
  "ipaddr.js": "1.9.1"
24864
24923
  },
24865
24924
  "engines": {
24866
24925
  "node": ">= 0.10"
24926
+ },
24927
+ "funding": {
24928
+ "type": "opencollective",
24929
+ "url": "https://opencollective.com/express"
24867
24930
  }
24868
24931
  },
24869
24932
  "node_modules/proxy-from-env": {
@@ -24930,12 +24993,13 @@
24930
24993
  }
24931
24994
  },
24932
24995
  "node_modules/qs": {
24933
- "version": "6.15.2",
24934
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
24935
- "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
24996
+ "version": "6.17.1",
24997
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
24998
+ "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
24936
24999
  "license": "BSD-3-Clause",
24937
25000
  "dependencies": {
24938
- "side-channel": "^1.1.0"
25001
+ "es-define-property": "^1.0.1",
25002
+ "side-channel": "^1.1.1"
24939
25003
  },
24940
25004
  "engines": {
24941
25005
  "node": ">=0.6"
@@ -25129,6 +25193,18 @@
25129
25193
  "node": ">=8.10.0"
25130
25194
  }
25131
25195
  },
25196
+ "node_modules/readdirp/node_modules/picomatch": {
25197
+ "version": "2.3.2",
25198
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
25199
+ "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
25200
+ "dev": true,
25201
+ "engines": {
25202
+ "node": ">=8.6"
25203
+ },
25204
+ "funding": {
25205
+ "url": "https://github.com/sponsors/jonschlinkert"
25206
+ }
25207
+ },
25132
25208
  "node_modules/rechoir": {
25133
25209
  "version": "0.6.2",
25134
25210
  "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
@@ -25830,21 +25906,10 @@
25830
25906
  "aws-dynamodb-local": "^0.0.14"
25831
25907
  }
25832
25908
  },
25833
- "node_modules/serverless-localstack": {
25834
- "version": "1.2.1",
25835
- "resolved": "https://registry.npmjs.org/serverless-localstack/-/serverless-localstack-1.2.1.tgz",
25836
- "integrity": "sha512-obvJHpRo1qRV05OdP7NXXDb6/o1g+oWwAP5GFbnBKpo5+46t15gDJ80LHKnIklT8kR45mNSEbVO6Iw+ctUYhRA==",
25837
- "dev": true,
25838
- "dependencies": {
25839
- "adm-zip": "^0.5.10",
25840
- "aws-sdk": "^2.402.0",
25841
- "es6-promisify": "^6.0.1"
25842
- }
25843
- },
25844
25909
  "node_modules/serverless-offline": {
25845
- "version": "13.8.1",
25846
- "resolved": "https://registry.npmjs.org/serverless-offline/-/serverless-offline-13.8.1.tgz",
25847
- "integrity": "sha512-7G/ohXl1qtPIAUHSt3K8mVXWWNdCyQnyIgAixEwBKHllAsbeCjv0/bkz/d0vqIkTGpyfVxnQ5MIhn6u3gZCQbg==",
25910
+ "version": "13.9.0",
25911
+ "resolved": "https://registry.npmjs.org/serverless-offline/-/serverless-offline-13.9.0.tgz",
25912
+ "integrity": "sha512-r/GU1FcgUbrhUzPJ5BOpni6JXhHVhxksYQH8d3S4alx4IZQo3E9Q8fT2z8Mvh+d0rfQ1Y0kHvyeKJ126rleGfg==",
25848
25913
  "dev": true,
25849
25914
  "dependencies": {
25850
25915
  "@aws-sdk/client-lambda": "^3.636.0",
@@ -26694,14 +26759,14 @@
26694
26759
  }
26695
26760
  },
26696
26761
  "node_modules/side-channel": {
26697
- "version": "1.1.0",
26698
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
26699
- "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
26762
+ "version": "1.1.1",
26763
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
26764
+ "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
26700
26765
  "license": "MIT",
26701
26766
  "dependencies": {
26702
26767
  "es-errors": "^1.3.0",
26703
- "object-inspect": "^1.13.3",
26704
- "side-channel-list": "^1.0.0",
26768
+ "object-inspect": "^1.13.4",
26769
+ "side-channel-list": "^1.0.1",
26705
26770
  "side-channel-map": "^1.0.1",
26706
26771
  "side-channel-weakmap": "^1.0.2"
26707
26772
  },
@@ -26713,13 +26778,13 @@
26713
26778
  }
26714
26779
  },
26715
26780
  "node_modules/side-channel-list": {
26716
- "version": "1.0.0",
26717
- "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
26718
- "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
26781
+ "version": "1.0.1",
26782
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
26783
+ "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
26719
26784
  "license": "MIT",
26720
26785
  "dependencies": {
26721
26786
  "es-errors": "^1.3.0",
26722
- "object-inspect": "^1.13.3"
26787
+ "object-inspect": "^1.13.4"
26723
26788
  },
26724
26789
  "engines": {
26725
26790
  "node": ">= 0.4"
@@ -27406,6 +27471,7 @@
27406
27471
  "version": "1.1.1",
27407
27472
  "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
27408
27473
  "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
27474
+ "devOptional": true,
27409
27475
  "dependencies": {
27410
27476
  "safe-buffer": "~5.1.0"
27411
27477
  }
@@ -27413,7 +27479,8 @@
27413
27479
  "node_modules/string_decoder/node_modules/safe-buffer": {
27414
27480
  "version": "5.1.2",
27415
27481
  "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
27416
- "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
27482
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
27483
+ "devOptional": true
27417
27484
  },
27418
27485
  "node_modules/string-length": {
27419
27486
  "version": "4.0.2",
@@ -28639,7 +28706,8 @@
28639
28706
  "node_modules/typedarray": {
28640
28707
  "version": "0.0.6",
28641
28708
  "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
28642
- "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA=="
28709
+ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
28710
+ "dev": true
28643
28711
  },
28644
28712
  "node_modules/typedarray.prototype.slice": {
28645
28713
  "version": "1.0.3",
@@ -28734,10 +28802,11 @@
28734
28802
  "license": "MIT"
28735
28803
  },
28736
28804
  "node_modules/undici-types": {
28737
- "version": "6.19.8",
28738
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
28739
- "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
28740
- "dev": true
28805
+ "version": "6.21.0",
28806
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
28807
+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
28808
+ "dev": true,
28809
+ "license": "MIT"
28741
28810
  },
28742
28811
  "node_modules/uni-global": {
28743
28812
  "version": "1.0.0",
@@ -28856,7 +28925,8 @@
28856
28925
  "node_modules/util-deprecate": {
28857
28926
  "version": "1.0.2",
28858
28927
  "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
28859
- "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
28928
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
28929
+ "devOptional": true
28860
28930
  },
28861
28931
  "node_modules/utils-merge": {
28862
28932
  "version": "1.0.1",
@@ -56,7 +56,7 @@
56
56
  "@types/aws-lambda": "^8.10.130",
57
57
  "@types/express": "^4.17.21",
58
58
  "@types/jest": "^29.5.11",
59
- "@types/node": "^20.10.5",
59
+ "@types/node": "^22.20.5",
60
60
  "@types/node-fetch": "^2.6.9",
61
61
  "@types/supertest": "^6.0.1",
62
62
  "@typescript-eslint/eslint-plugin": "^8.61.0",
@@ -64,6 +64,8 @@
64
64
  "class-transformer": "^0.5.1",
65
65
  "class-validator": "^0.14.0",
66
66
  "concurrently": "^9.0.1",
67
+ "dotenv": "^16.4.5",
68
+ "dotenv-expand": "^10.0.0",
67
69
  "eslint": "^8.56.0",
68
70
  "eslint-config-prettier": "^9.1.0",
69
71
  "eslint-plugin-import": "^2.29.1",
@@ -71,14 +73,13 @@
71
73
  "eslint-plugin-simple-import-sort": "^10.0.0",
72
74
  "jest": "^29.7.0",
73
75
  "jest-junit": "^16.0.0",
74
- "js-yaml": "^4.1.0",
76
+ "js-yaml": "^4.3.2",
75
77
  "nestjs-spelunker": "^1.3.0",
76
78
  "prettier": "^3.1.1",
77
79
  "run-script-os": "^1.1.6",
78
80
  "serverless": "^3.40.0",
79
81
  "serverless-dynamodb": "^0.2.47",
80
- "serverless-localstack": "^1.1.2",
81
- "serverless-offline": "^13.3.2",
82
+ "serverless-offline": "^13.9.0",
82
83
  "serverless-offline-aws-eventbridge": "^2.1.0",
83
84
  "serverless-offline-dynamodb-streams": "^7.0.0",
84
85
  "serverless-offline-lambda": "^1.0.6",
@@ -124,13 +125,16 @@
124
125
  "trim-newlines": "^3.0.1",
125
126
  "jsonwebtoken": "^9.0.2",
126
127
  "lodash": "^4.18.0",
127
- "js-yaml": "4.1.1",
128
+ "js-yaml": "$js-yaml",
128
129
  "tmp": "^0.2.6",
129
- "qs": "^6.14.2",
130
+ "qs": "^6.16.1",
130
131
  "yaml": "^2.8.3",
131
132
  "follow-redirects": "^1.16.0",
132
133
  "flatted": "^3.4.2",
133
- "multer": "^2.2.0",
134
+ "multer": "^2.5.0",
135
+ "proxy-addr": "^2.0.8",
136
+ "body-parser@1": "^1.20.9",
137
+ "body-parser@2": "^2.4.0",
134
138
  "@angular-devkit/core": {
135
139
  "ajv": "^8.18.0",
136
140
  "picomatch": "^4.0.4"
@@ -140,5 +144,8 @@
140
144
  "@aws-sdk/core": {
141
145
  "fast-xml-parser": "^5.7.3"
142
146
  }
147
+ },
148
+ "engines": {
149
+ "node": ">=22"
143
150
  }
144
151
  }
@@ -10,10 +10,13 @@ import {
10
10
  UpdateTimeToLiveCommand,
11
11
  } from '@aws-sdk/client-dynamodb'
12
12
  import dotenv from 'dotenv'
13
+ import { expand } from 'dotenv-expand'
13
14
  import { appendFileSync, readFileSync, readdirSync, writeFileSync } from 'fs'
14
15
  import path from 'path'
15
16
 
16
- dotenv.config()
17
+ // .env.local writes endpoints as http://localhost:${LOCAL_X_PORT:-NNNN};
18
+ // plain dotenv would leave that literal, so expand it like Serverless does.
19
+ expand(dotenv.config())
17
20
 
18
21
  const envFilePath = './.env'
19
22
  const tableDir = path.join(__dirname, 'dynamodbs')