skuba 12.1.0-no-sync-in-promise-iterable-20250801120322 → 12.1.1
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 +1 -2
- package/config/tsconfig.json +3 -2
- package/lib/cli/build/assets.js +1 -1
- package/lib/cli/build/assets.js.map +2 -2
- package/lib/cli/configure/analyseDependencies.d.ts +2 -2
- package/lib/cli/configure/analyseDependencies.js.map +1 -1
- package/lib/cli/configure/analysis/package.d.ts +1 -1
- package/lib/cli/configure/analysis/package.js +1 -1
- package/lib/cli/configure/analysis/package.js.map +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.d.ts +2 -2
- package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
- package/lib/cli/configure/getEntryPoint.d.ts +2 -2
- package/lib/cli/configure/getEntryPoint.js.map +1 -1
- package/lib/cli/configure/getProjectType.d.ts +2 -2
- package/lib/cli/configure/getProjectType.js.map +1 -1
- package/lib/cli/configure/processing/package.js +8 -2
- package/lib/cli/configure/processing/package.js.map +2 -2
- package/lib/cli/init/getConfig.js +1 -1
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/lint/internal.js +1 -1
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
- package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
- package/lib/cli/test/index.d.ts +1 -1
- package/lib/cli/test/index.js +18 -4
- package/lib/cli/test/index.js.map +2 -2
- package/lib/utils/manifest.d.ts +1 -1
- package/lib/utils/manifest.js +1 -1
- package/lib/utils/manifest.js.map +2 -2
- package/package.json +13 -13
- package/template/base/_pnpm-workspace.yaml +1 -0
- package/template/base/jest.setup.ts +1 -1
- package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/express-rest-api/.env +1 -1
- package/template/express-rest-api/.gantry/dev.yml +5 -1
- package/template/express-rest-api/.gantry/prod.yml +5 -1
- package/template/express-rest-api/Dockerfile +1 -1
- package/template/express-rest-api/README.md +5 -5
- package/template/express-rest-api/gantry.apply.yml +17 -1
- package/template/express-rest-api/package.json +11 -5
- package/template/express-rest-api/src/api/healthCheck.ts +2 -2
- package/template/express-rest-api/src/config.ts +7 -7
- package/template/express-rest-api/src/framework/logging.ts +11 -7
- package/template/express-rest-api/src/framework/metrics.ts +1 -1
- package/template/express-rest-api/src/tracing.ts +56 -0
- package/template/greeter/README.md +2 -2
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
- package/template/koa-rest-api/.env +1 -1
- package/template/koa-rest-api/.gantry/dev.yml +3 -3
- package/template/koa-rest-api/.gantry/prod.yml +3 -3
- package/template/koa-rest-api/README.md +6 -6
- package/template/koa-rest-api/gantry.apply.yml +15 -3
- package/template/koa-rest-api/package.json +5 -6
- package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
- package/template/koa-rest-api/src/config.ts +7 -7
- package/template/koa-rest-api/src/framework/logging.ts +12 -8
- package/template/koa-rest-api/src/framework/metrics.ts +1 -1
- package/template/koa-rest-api/src/framework/server.test.ts +7 -8
- package/template/koa-rest-api/src/framework/server.ts +1 -4
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
- package/template/lambda-sqs-worker-cdk/.env +1 -1
- package/template/lambda-sqs-worker-cdk/README.md +8 -8
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +36 -10
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -8
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +11 -5
- package/template/lambda-sqs-worker-cdk/infra/config.ts +27 -18
- package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +6 -6
- package/template/lambda-sqs-worker-cdk/src/app.test.ts +4 -4
- package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
- package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +2 -2
- package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +8 -21
- package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +12 -8
- package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
- package/template/oss-npm-package/.github/workflows/release.yml +1 -1
- package/template/oss-npm-package/.github/workflows/validate.yml +1 -1
|
@@ -1,55 +1,64 @@
|
|
|
1
1
|
import { Env } from 'skuba-dive';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type Deployment = (typeof deployments)[number];
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const deployments = ['dev', 'prod'] as const;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const deployment = Env.oneOf(deployments)('DEPLOYMENT');
|
|
8
8
|
|
|
9
9
|
interface Config {
|
|
10
|
-
|
|
10
|
+
env: 'development' | 'production';
|
|
11
|
+
service: string;
|
|
12
|
+
version: string;
|
|
13
|
+
|
|
11
14
|
workerLambda: {
|
|
12
15
|
batchSize: number;
|
|
13
16
|
reservedConcurrency: number;
|
|
14
17
|
environment: {
|
|
15
|
-
|
|
16
|
-
SERVICE: string;
|
|
17
|
-
VERSION: string;
|
|
18
|
+
DEPLOYMENT: Deployment;
|
|
18
19
|
};
|
|
19
20
|
};
|
|
21
|
+
|
|
20
22
|
datadogApiKeySecretArn: string;
|
|
21
23
|
sourceSnsTopicArn: string;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
const
|
|
26
|
+
const service = '<%- serviceName %>';
|
|
27
|
+
const version = Env.string('VERSION');
|
|
28
|
+
|
|
29
|
+
const configs: Record<Deployment, Config> = {
|
|
25
30
|
dev: {
|
|
26
|
-
|
|
31
|
+
env: 'development',
|
|
32
|
+
service,
|
|
33
|
+
version,
|
|
34
|
+
|
|
27
35
|
workerLambda: {
|
|
28
36
|
batchSize: 10,
|
|
29
|
-
reservedConcurrency:
|
|
37
|
+
reservedConcurrency: 3,
|
|
30
38
|
environment: {
|
|
31
|
-
|
|
32
|
-
SERVICE: '<%- serviceName %>',
|
|
33
|
-
VERSION: Env.string('VERSION', { default: 'local' }),
|
|
39
|
+
DEPLOYMENT: 'dev',
|
|
34
40
|
},
|
|
35
41
|
},
|
|
42
|
+
|
|
36
43
|
datadogApiKeySecretArn: 'TODO: datadogApiKeySecretArn',
|
|
37
44
|
sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
|
|
38
45
|
},
|
|
39
46
|
prod: {
|
|
40
|
-
|
|
47
|
+
env: 'production',
|
|
48
|
+
service,
|
|
49
|
+
version,
|
|
50
|
+
|
|
41
51
|
workerLambda: {
|
|
42
52
|
batchSize: 10,
|
|
43
53
|
reservedConcurrency: 20,
|
|
44
54
|
environment: {
|
|
45
|
-
|
|
46
|
-
SERVICE: '<%- serviceName %>',
|
|
47
|
-
VERSION: Env.string('VERSION', { default: 'local' }),
|
|
55
|
+
DEPLOYMENT: 'prod',
|
|
48
56
|
},
|
|
49
57
|
},
|
|
58
|
+
|
|
50
59
|
datadogApiKeySecretArn: 'TODO: datadogApiKeySecretArn',
|
|
51
60
|
sourceSnsTopicArn: 'TODO: sourceSnsTopicArn',
|
|
52
61
|
},
|
|
53
62
|
};
|
|
54
63
|
|
|
55
|
-
export const config: Config = configs[
|
|
64
|
+
export const config: Config = configs[deployment];
|
|
@@ -7,7 +7,7 @@ import { config } from './config.js';
|
|
|
7
7
|
const app = new App();
|
|
8
8
|
|
|
9
9
|
const appStack = new AppStack(app, 'appStack', {
|
|
10
|
-
stackName: config.
|
|
10
|
+
stackName: config.service,
|
|
11
11
|
tags: {
|
|
12
12
|
'seek:source:url': 'https://github.com/SEEK-Jobs/<%- repoName %>',
|
|
13
13
|
// 'seek:system:name': 'TODO: https://rfc.skinfra.xyz/RFC051-AWS-Tagging-Standard.html#tagging-schema',
|
|
@@ -18,9 +18,7 @@
|
|
|
18
18
|
"@aws-sdk/client-lambda": "^3.363.0",
|
|
19
19
|
"@aws-sdk/client-sns": "^3.363.0",
|
|
20
20
|
"@seek/aws-codedeploy-hooks": "^2.0.0",
|
|
21
|
-
"@seek/logger": "
|
|
22
|
-
"datadog-lambda-js": "^10.0.0",
|
|
23
|
-
"dd-trace": "^5.0.0",
|
|
21
|
+
"@seek/logger": "11.0.0",
|
|
24
22
|
"skuba-dive": "^2.0.0",
|
|
25
23
|
"zod": "^4.0.0"
|
|
26
24
|
},
|
|
@@ -35,11 +33,13 @@
|
|
|
35
33
|
"aws-sdk-client-mock-jest": "^4.0.0",
|
|
36
34
|
"chance": "^1.1.8",
|
|
37
35
|
"constructs": "^10.0.17",
|
|
38
|
-
"datadog-cdk-constructs-v2": "^
|
|
36
|
+
"datadog-cdk-constructs-v2": "^3.0.0",
|
|
37
|
+
"datadog-lambda-js": "^12.0.0",
|
|
38
|
+
"dd-trace": "^5.0.0",
|
|
39
39
|
"pino-pretty": "^13.0.0",
|
|
40
|
-
"skuba": "
|
|
40
|
+
"skuba": "*"
|
|
41
41
|
},
|
|
42
|
-
"packageManager": "pnpm@10.
|
|
42
|
+
"packageManager": "pnpm@10.14.0",
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=22"
|
|
45
45
|
}
|
|
@@ -107,7 +107,7 @@ describe('handler', () => {
|
|
|
107
107
|
expect(stdoutMock.calls).toMatchObject([
|
|
108
108
|
{ count: 2, level: 20, msg: 'Received jobs' },
|
|
109
109
|
{
|
|
110
|
-
|
|
110
|
+
error: {
|
|
111
111
|
name: 'ZodError',
|
|
112
112
|
type: 'ZodError',
|
|
113
113
|
},
|
|
@@ -151,7 +151,7 @@ describe('handler', () => {
|
|
|
151
151
|
expect(stdoutMock.calls).toMatchObject([
|
|
152
152
|
{ count: 1, level: 20, msg: 'Received jobs' },
|
|
153
153
|
{
|
|
154
|
-
|
|
154
|
+
error: {
|
|
155
155
|
message: err.message,
|
|
156
156
|
type: 'Error',
|
|
157
157
|
},
|
|
@@ -181,7 +181,7 @@ describe('handler', () => {
|
|
|
181
181
|
msg: 'Received jobs',
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
|
|
184
|
+
error: {
|
|
185
185
|
message: err.message,
|
|
186
186
|
type: 'Error',
|
|
187
187
|
},
|
|
@@ -203,7 +203,7 @@ describe('handler', () => {
|
|
|
203
203
|
|
|
204
204
|
expect(stdoutMock.calls).toMatchObject([
|
|
205
205
|
{
|
|
206
|
-
|
|
206
|
+
error: {
|
|
207
207
|
message: 'Received 0 records',
|
|
208
208
|
type: 'Error',
|
|
209
209
|
},
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { Env } from 'skuba-dive';
|
|
2
2
|
|
|
3
3
|
interface Config {
|
|
4
|
-
|
|
4
|
+
deployment: Deployment;
|
|
5
5
|
|
|
6
6
|
logLevel: string;
|
|
7
|
-
metrics: boolean;
|
|
8
7
|
name: string;
|
|
9
8
|
version: string;
|
|
10
9
|
|
|
11
10
|
destinationSnsTopicArn: string;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
type
|
|
13
|
+
type Deployment = (typeof deployments)[number];
|
|
15
14
|
|
|
16
|
-
const
|
|
15
|
+
const deployments = ['local', 'test', 'dev', 'prod'] as const;
|
|
17
16
|
|
|
18
|
-
const
|
|
17
|
+
const deployment = Env.oneOf(deployments)('DEPLOYMENT');
|
|
19
18
|
|
|
20
19
|
/* istanbul ignore next: config verification makes more sense in a smoke test */
|
|
21
|
-
const configs: Record<
|
|
20
|
+
const configs: Record<Deployment, () => Omit<Config, 'deployment'>> = {
|
|
22
21
|
local: () => ({
|
|
23
22
|
logLevel: 'debug',
|
|
24
|
-
metrics: false,
|
|
25
23
|
name: '<%- serviceName %>',
|
|
26
24
|
version: 'local',
|
|
27
25
|
|
|
@@ -30,7 +28,6 @@ const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
|
|
|
30
28
|
|
|
31
29
|
test: () => ({
|
|
32
30
|
logLevel: Env.string('LOG_LEVEL', { default: 'debug' }),
|
|
33
|
-
metrics: false,
|
|
34
31
|
name: '<%- serviceName %>',
|
|
35
32
|
version: 'test',
|
|
36
33
|
|
|
@@ -39,24 +36,22 @@ const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
|
|
|
39
36
|
|
|
40
37
|
dev: () => ({
|
|
41
38
|
logLevel: 'debug',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
version: Env.string('VERSION'),
|
|
39
|
+
name: Env.string('DD_SERVICE'),
|
|
40
|
+
version: Env.string('DD_VERSION'),
|
|
45
41
|
|
|
46
42
|
destinationSnsTopicArn: Env.string('DESTINATION_SNS_TOPIC_ARN'),
|
|
47
43
|
}),
|
|
48
44
|
|
|
49
45
|
prod: () => ({
|
|
50
46
|
logLevel: 'info',
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
version: Env.string('VERSION'),
|
|
47
|
+
name: Env.string('DD_SERVICE'),
|
|
48
|
+
version: Env.string('DD_VERSION'),
|
|
54
49
|
|
|
55
50
|
destinationSnsTopicArn: Env.string('DESTINATION_SNS_TOPIC_ARN'),
|
|
56
51
|
}),
|
|
57
52
|
};
|
|
58
53
|
|
|
59
54
|
export const config: Config = {
|
|
60
|
-
...configs[
|
|
61
|
-
|
|
55
|
+
...configs[deployment](),
|
|
56
|
+
deployment,
|
|
62
57
|
};
|
|
@@ -52,7 +52,7 @@ describe('createHandler', () => {
|
|
|
52
52
|
expect(stdoutMock.calls).toMatchObject([
|
|
53
53
|
{
|
|
54
54
|
awsRequestId: '-',
|
|
55
|
-
|
|
55
|
+
error: {
|
|
56
56
|
message: err.message,
|
|
57
57
|
type: 'Error',
|
|
58
58
|
},
|
|
@@ -74,7 +74,7 @@ describe('createHandler', () => {
|
|
|
74
74
|
expect(stdoutMock.calls).toMatchObject([
|
|
75
75
|
{
|
|
76
76
|
awsRequestId: '-',
|
|
77
|
-
|
|
77
|
+
error: {
|
|
78
78
|
message: err.message,
|
|
79
79
|
type: 'Error',
|
|
80
80
|
},
|
|
@@ -5,9 +5,7 @@ import type {
|
|
|
5
5
|
SQSEvent,
|
|
6
6
|
SQSRecord,
|
|
7
7
|
} from 'aws-lambda';
|
|
8
|
-
import { datadog } from 'datadog-lambda-js';
|
|
9
8
|
|
|
10
|
-
import { config } from 'src/config.js';
|
|
11
9
|
import { lambdaContext, logger, recordContext } from 'src/framework/logging.js';
|
|
12
10
|
|
|
13
11
|
type Handler<Event, Output> = (
|
|
@@ -15,21 +13,11 @@ type Handler<Event, Output> = (
|
|
|
15
13
|
ctx: LambdaContext,
|
|
16
14
|
) => Promise<Output>;
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const withDatadog = <Event, Output = unknown>(
|
|
24
|
-
fn: Handler<Event, Output>,
|
|
25
|
-
): Handler<Event, Output> =>
|
|
26
|
-
// istanbul ignore next
|
|
27
|
-
config.metrics ? (datadog(fn) as Handler<Event, Output>) : fn;
|
|
28
|
-
|
|
29
|
-
export const createHandler = <Event extends SQSEvent, Output = unknown>(
|
|
30
|
-
fn: (event: Event, ctx: LambdaContext) => Promise<Output>,
|
|
31
|
-
) =>
|
|
32
|
-
withDatadog<Event>((event, ctx) =>
|
|
16
|
+
export const createHandler =
|
|
17
|
+
<Event extends SQSEvent, Output = unknown>(
|
|
18
|
+
fn: (event: Event, ctx: LambdaContext) => Promise<Output>,
|
|
19
|
+
): Handler<Event, Output> =>
|
|
20
|
+
async (event, ctx) =>
|
|
33
21
|
lambdaContext.run({ awsRequestId: ctx.awsRequestId }, async () => {
|
|
34
22
|
try {
|
|
35
23
|
const output = await fn(event, ctx);
|
|
@@ -38,12 +26,11 @@ export const createHandler = <Event extends SQSEvent, Output = unknown>(
|
|
|
38
26
|
|
|
39
27
|
return output;
|
|
40
28
|
} catch (err) {
|
|
41
|
-
logger.error(
|
|
29
|
+
logger.error(err, 'Function failed');
|
|
42
30
|
|
|
43
31
|
throw new Error('Function failed');
|
|
44
32
|
}
|
|
45
|
-
})
|
|
46
|
-
);
|
|
33
|
+
});
|
|
47
34
|
|
|
48
35
|
export const createBatchSQSHandler =
|
|
49
36
|
(
|
|
@@ -58,7 +45,7 @@ export const createBatchSQSHandler =
|
|
|
58
45
|
await fn(record, ctx);
|
|
59
46
|
return;
|
|
60
47
|
} catch (err) {
|
|
61
|
-
logger.error(
|
|
48
|
+
logger.error(err, 'Processing record failed');
|
|
62
49
|
return {
|
|
63
50
|
itemIdentifier: record.messageId,
|
|
64
51
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { createDestination, createLogger } from '@seek/logger';
|
|
4
4
|
|
|
5
5
|
import { config } from 'src/config.js';
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ export const lambdaContext = new AsyncLocalStorage<LambdaContext>();
|
|
|
16
16
|
export const recordContext = new AsyncLocalStorage<RecordContext>();
|
|
17
17
|
|
|
18
18
|
const { destination, stdoutMock } = createDestination({
|
|
19
|
-
mock: config.
|
|
19
|
+
mock: config.deployment === 'test' && {
|
|
20
20
|
redact: ['awsRequestId'],
|
|
21
21
|
},
|
|
22
22
|
});
|
|
@@ -25,9 +25,15 @@ export { stdoutMock };
|
|
|
25
25
|
|
|
26
26
|
export const logger = createLogger(
|
|
27
27
|
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
eeeoh: {
|
|
29
|
+
/**
|
|
30
|
+
* TODO: choose an appropriate Datadog log tier.
|
|
31
|
+
*
|
|
32
|
+
* https://github.com/seek-oss/logger/blob/master/docs/eeeoh.md#datadog-log-tiers
|
|
33
|
+
*/
|
|
34
|
+
datadog: 'tin',
|
|
35
|
+
team: '<%- teamName %>',
|
|
36
|
+
use: 'environment',
|
|
31
37
|
},
|
|
32
38
|
|
|
33
39
|
level: config.logLevel,
|
|
@@ -37,10 +43,8 @@ export const logger = createLogger(
|
|
|
37
43
|
...recordContext.getStore(),
|
|
38
44
|
}),
|
|
39
45
|
|
|
40
|
-
name: config.name,
|
|
41
|
-
|
|
42
46
|
transport:
|
|
43
|
-
config.
|
|
47
|
+
config.deployment === 'local' ? { target: 'pino-pretty' } : undefined,
|
|
44
48
|
},
|
|
45
49
|
destination,
|
|
46
50
|
);
|
|
@@ -7,8 +7,5 @@ const prefix = `${config.name}.`;
|
|
|
7
7
|
export const metricsClient = {
|
|
8
8
|
distribution: (
|
|
9
9
|
...[name, ...rest]: Parameters<typeof sendDistributionMetric>
|
|
10
|
-
) =>
|
|
11
|
-
config.metrics
|
|
12
|
-
? sendDistributionMetric(`${prefix}${name}`, ...rest)
|
|
13
|
-
: undefined,
|
|
10
|
+
) => sendDistributionMetric(`${prefix}${name}`, ...rest),
|
|
14
11
|
};
|