skuba 12.1.0-main-20250810101347 → 12.1.0-main-20250812041011
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/lib/cli/build/assets.js +1 -1
- package/lib/cli/build/assets.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/patches/8.2.1/upgradeESLint.js +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
- package/package.json +4 -4
- 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 +9 -3
- 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 +1 -1
- 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 +2 -3
- 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 -7
- 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 +34 -8
- 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 +26 -17
- package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +5 -5
- 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
|
@@ -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": "^12.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,9 +33,11 @@
|
|
|
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": "12.1.0-main-
|
|
40
|
+
"skuba": "12.1.0-main-20250812041011"
|
|
41
41
|
},
|
|
42
42
|
"packageManager": "pnpm@10.14.0",
|
|
43
43
|
"engines": {
|
|
@@ -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
|
};
|