skuba 13.0.0-custom-conditions-exports-20250730235248 → 13.0.0-custom-conditions-exports-20250923005538

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.
Files changed (136) hide show
  1. package/README.md +1 -2
  2. package/config/tsconfig.json +2 -1
  3. package/jest/moduleNameMapper.js +3 -0
  4. package/lib/cli/build/assets.js +1 -1
  5. package/lib/cli/build/assets.js.map +2 -2
  6. package/lib/cli/build/esbuild.js +1 -1
  7. package/lib/cli/build/esbuild.js.map +2 -2
  8. package/lib/cli/build/index.js +1 -1
  9. package/lib/cli/build/index.js.map +2 -2
  10. package/lib/cli/build/tsc.d.ts +9 -2
  11. package/lib/cli/build/tsc.js +76 -40
  12. package/lib/cli/build/tsc.js.map +3 -3
  13. package/lib/cli/configure/analyseDependencies.d.ts +2 -2
  14. package/lib/cli/configure/analyseDependencies.js.map +1 -1
  15. package/lib/cli/configure/analysis/package.d.ts +1 -1
  16. package/lib/cli/configure/analysis/package.js +1 -1
  17. package/lib/cli/configure/analysis/package.js.map +2 -2
  18. package/lib/cli/configure/ensureTemplateCompletion.d.ts +2 -2
  19. package/lib/cli/configure/ensureTemplateCompletion.js.map +1 -1
  20. package/lib/cli/configure/getEntryPoint.d.ts +2 -2
  21. package/lib/cli/configure/getEntryPoint.js.map +1 -1
  22. package/lib/cli/configure/getProjectType.d.ts +2 -2
  23. package/lib/cli/configure/getProjectType.js.map +1 -1
  24. package/lib/cli/configure/processing/package.js +8 -2
  25. package/lib/cli/configure/processing/package.js.map +2 -2
  26. package/lib/cli/init/getConfig.js +1 -1
  27. package/lib/cli/init/getConfig.js.map +2 -2
  28. package/lib/cli/lint/internal.js +1 -1
  29. package/lib/cli/lint/internal.js.map +2 -2
  30. package/lib/cli/lint/internalLints/patchRenovateConfig.js +2 -2
  31. package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +1 -1
  32. package/lib/cli/lint/internalLints/upgrade/index.d.ts +2 -2
  33. package/lib/cli/lint/internalLints/upgrade/index.js.map +1 -1
  34. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js +3 -8
  35. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/index.js.map +2 -2
  36. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.d.ts +4 -0
  37. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js +162 -0
  38. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/unhandledRejections.js.map +7 -0
  39. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.d.ts +2 -0
  40. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js +35 -0
  41. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/index.js.map +7 -0
  42. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.d.ts +3 -0
  43. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js +105 -0
  44. package/lib/cli/lint/internalLints/upgrade/patches/12.1.1/patchJestSnapshots.js.map +7 -0
  45. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/configureTsConfigForESM.d.ts +23 -0
  46. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/configureTsConfigForESM.js +321 -0
  47. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/configureTsConfigForESM.js.map +7 -0
  48. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/index.d.ts +2 -0
  49. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/index.js +40 -0
  50. package/lib/cli/lint/internalLints/upgrade/patches/12.2.0/index.js.map +7 -0
  51. package/lib/cli/lint/internalLints/upgrade/patches/{12.0.2 → 12.2.0}/rewriteSrcImports.js +7 -4
  52. package/lib/cli/lint/internalLints/upgrade/patches/{12.0.2 → 12.2.0}/rewriteSrcImports.js.map +3 -3
  53. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js +1 -1
  54. package/lib/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.js.map +2 -2
  55. package/lib/cli/node/index.js +6 -0
  56. package/lib/cli/node/index.js.map +2 -2
  57. package/lib/cli/start/index.js +6 -0
  58. package/lib/cli/start/index.js.map +2 -2
  59. package/lib/cli/test/index.d.ts +1 -1
  60. package/lib/cli/test/index.js +18 -4
  61. package/lib/cli/test/index.js.map +2 -2
  62. package/lib/utils/args.d.ts +2 -0
  63. package/lib/utils/args.js +5 -0
  64. package/lib/utils/args.js.map +2 -2
  65. package/lib/utils/manifest.d.ts +1 -1
  66. package/lib/utils/manifest.js +1 -1
  67. package/lib/utils/manifest.js.map +2 -2
  68. package/lib/utils/template.d.ts +1 -1
  69. package/package.json +17 -20
  70. package/template/base/_.prettierrc.js +1 -1
  71. package/template/base/_eslint.config.js +1 -1
  72. package/template/base/_pnpm-workspace.yaml +1 -0
  73. package/template/base/jest.setup.ts +1 -1
  74. package/template/base/tsconfig.build.json +3 -0
  75. package/template/base/tsconfig.json +0 -1
  76. package/template/express-rest-api/.buildkite/pipeline.yml +6 -0
  77. package/template/express-rest-api/.env +1 -1
  78. package/template/express-rest-api/.gantry/dev.yml +5 -1
  79. package/template/express-rest-api/.gantry/prod.yml +5 -1
  80. package/template/express-rest-api/Dockerfile +1 -1
  81. package/template/express-rest-api/Dockerfile.dev-deps +1 -1
  82. package/template/express-rest-api/README.md +5 -5
  83. package/template/express-rest-api/gantry.apply.yml +17 -1
  84. package/template/express-rest-api/package.json +11 -5
  85. package/template/express-rest-api/src/api/healthCheck.ts +2 -2
  86. package/template/express-rest-api/src/config.ts +7 -7
  87. package/template/express-rest-api/src/framework/logging.ts +11 -7
  88. package/template/express-rest-api/src/framework/metrics.ts +1 -1
  89. package/template/express-rest-api/src/listen.ts +6 -0
  90. package/template/express-rest-api/src/tracing.ts +56 -0
  91. package/template/greeter/Dockerfile +1 -1
  92. package/template/greeter/README.md +2 -2
  93. package/template/greeter/package.json +2 -2
  94. package/template/koa-rest-api/.buildkite/pipeline.yml +6 -0
  95. package/template/koa-rest-api/.env +1 -1
  96. package/template/koa-rest-api/.gantry/dev.yml +3 -3
  97. package/template/koa-rest-api/.gantry/prod.yml +3 -3
  98. package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
  99. package/template/koa-rest-api/README.md +6 -6
  100. package/template/koa-rest-api/gantry.apply.yml +15 -3
  101. package/template/koa-rest-api/package.json +10 -11
  102. package/template/koa-rest-api/skuba.template.js +1 -1
  103. package/template/koa-rest-api/src/api/healthCheck.ts +2 -2
  104. package/template/koa-rest-api/src/config.ts +7 -7
  105. package/template/koa-rest-api/src/framework/logging.ts +12 -8
  106. package/template/koa-rest-api/src/framework/metrics.ts +1 -1
  107. package/template/koa-rest-api/src/framework/server.test.ts +7 -8
  108. package/template/koa-rest-api/src/framework/server.ts +1 -4
  109. package/template/koa-rest-api/src/listen.ts +6 -0
  110. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +6 -2
  111. package/template/lambda-sqs-worker-cdk/.env +1 -1
  112. package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
  113. package/template/lambda-sqs-worker-cdk/README.md +8 -8
  114. package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +54 -26
  115. package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +5 -22
  116. package/template/lambda-sqs-worker-cdk/infra/appStack.ts +16 -9
  117. package/template/lambda-sqs-worker-cdk/infra/config.ts +34 -20
  118. package/template/lambda-sqs-worker-cdk/infra/index.ts +1 -1
  119. package/template/lambda-sqs-worker-cdk/package.json +7 -9
  120. package/template/lambda-sqs-worker-cdk/src/app.test.ts +91 -51
  121. package/template/lambda-sqs-worker-cdk/src/app.ts +10 -9
  122. package/template/lambda-sqs-worker-cdk/src/config.ts +11 -16
  123. package/template/lambda-sqs-worker-cdk/src/framework/handler.test.ts +10 -5
  124. package/template/lambda-sqs-worker-cdk/src/framework/handler.ts +48 -24
  125. package/template/lambda-sqs-worker-cdk/src/framework/logging.ts +23 -11
  126. package/template/lambda-sqs-worker-cdk/src/framework/metrics.ts +1 -4
  127. package/template/lambda-sqs-worker-cdk/src/testing/handler.ts +4 -1
  128. package/template/lambda-sqs-worker-cdk/tsconfig.json +1 -2
  129. package/template/oss-npm-package/.github/workflows/release.yml +5 -6
  130. package/template/oss-npm-package/.github/workflows/validate.yml +5 -5
  131. package/template/oss-npm-package/_package.json +0 -3
  132. package/template/oss-npm-package/skuba.template.js +1 -1
  133. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/configureTsConfigForESM.d.ts +0 -6
  134. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/configureTsConfigForESM.js +0 -248
  135. package/lib/cli/lint/internalLints/upgrade/patches/12.0.2/configureTsConfigForESM.js.map +0 -7
  136. /package/lib/cli/lint/internalLints/upgrade/patches/{12.0.2 → 12.2.0}/rewriteSrcImports.d.ts +0 -0
@@ -0,0 +1,56 @@
1
+ /**
2
+ * OpenTelemetry tracing initialisation. This is a standalone TS/JS module that is not
3
+ * referenced by application source code directly. It is required at runtime using the
4
+ * node command's `--require` argument, see Dockerfile for details.
5
+ */
6
+
7
+ import { propagation } from '@opentelemetry/api';
8
+ import { CompositePropagator } from '@opentelemetry/core';
9
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
10
+ import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
11
+ import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
12
+ import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';
13
+ import { NodeSDK } from '@opentelemetry/sdk-node';
14
+
15
+ const app = 'opentelemetry';
16
+ const log = (level: string, msg: string, extra = {}) => {
17
+ const toLog = { msg, level, app, time: new Date().toISOString(), ...extra };
18
+ console.log(JSON.stringify(toLog)); // eslint-disable-line no-console
19
+ };
20
+
21
+ const main = () => {
22
+ // Use B3 propagation to ensure proper propagation between systems that use
23
+ // OpenTelemetry and native Datadog APM, such as Istio/Envoy.
24
+ propagation.setGlobalPropagator(
25
+ new CompositePropagator({
26
+ propagators: [
27
+ new B3Propagator(),
28
+ new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }),
29
+ ],
30
+ }),
31
+ );
32
+
33
+ const sdk = new NodeSDK({
34
+ traceExporter: new OTLPTraceExporter(),
35
+ autoDetectResources: false,
36
+ instrumentations: [new HttpInstrumentation(), new AwsInstrumentation()],
37
+ });
38
+
39
+ sdk.start();
40
+
41
+ process.on('SIGTERM', () => {
42
+ sdk
43
+ .shutdown()
44
+ .then(() => log('info', 'OpenTelemetry successfully terminated'))
45
+ .catch((err: Error) =>
46
+ log('error', 'OpenTelemetry failed to terminate', { err }),
47
+ )
48
+ .finally(() => process.exit(0)); // eslint-disable-line no-process-exit
49
+ });
50
+ };
51
+
52
+ if (process.env.OPENTELEMETRY_ENABLED === 'true') {
53
+ main();
54
+ } else {
55
+ log('info', 'OpenTelemetry not enabled');
56
+ }
@@ -1,4 +1,4 @@
1
- # syntax=docker/dockerfile:1.17
1
+ # syntax=docker/dockerfile:1.18
2
2
 
3
3
  FROM public.ecr.aws/docker/library/node:22-alpine AS dev-deps
4
4
 
@@ -75,7 +75,7 @@ For inspiration in this space, check out:
75
75
 
76
76
  ### Dev
77
77
 
78
- TODO: add support links for the dev environment.
78
+ TODO: add support links for the dev deployment.
79
79
 
80
80
  <!--
81
81
  - CloudWatch dashboard
@@ -85,7 +85,7 @@ TODO: add support links for the dev environment.
85
85
 
86
86
  ### Prod
87
87
 
88
- TODO: add support links for the prod environment.
88
+ TODO: add support links for the prod deployment.
89
89
 
90
90
  <!--
91
91
  - CloudWatch dashboard
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^22.13.10",
26
- "skuba": "13.0.0-custom-conditions-exports-20250730235248"
26
+ "skuba": "13.0.0-custom-conditions-exports-20250923005538"
27
27
  },
28
- "packageManager": "pnpm@10.12.4",
28
+ "packageManager": "pnpm@10.15.1",
29
29
  "engines": {
30
30
  "node": ">=22"
31
31
  }
@@ -77,6 +77,9 @@ steps:
77
77
  queue: <%- devBuildkiteQueueName %>
78
78
  label: 🤞 Deploy Dev
79
79
  concurrency_group: <%- teamName %>/deploy/gantry/<%- devGantryEnvironmentName %>
80
+ env:
81
+ DD_DEPLOYMENT_ENVIRONMENT: development
82
+ DD_DEPLOYMENT_SERVICE: <%- serviceName %>
80
83
  key: deploy-dev
81
84
  plugins:
82
85
  - seek-jobs/gantry#v4.0.0:
@@ -93,6 +96,9 @@ steps:
93
96
  branches: ${BUILDKITE_PIPELINE_DEFAULT_BRANCH}
94
97
  concurrency_group: <%- teamName %>/deploy/gantry/<%- prodGantryEnvironmentName %>
95
98
  depends_on: deploy-dev
99
+ env:
100
+ DD_DEPLOYMENT_ENVIRONMENT: production
101
+ DD_DEPLOYMENT_SERVICE: <%- serviceName %>
96
102
  plugins:
97
103
  - seek-jobs/gantry#v4.0.0:
98
104
  command: apply
@@ -1 +1 @@
1
- ENVIRONMENT=local
1
+ DEPLOYMENT=local
@@ -1,4 +1,5 @@
1
- environment: dev
1
+ deployment: dev
2
+ env: development
2
3
 
3
4
  maxInstanceCount: 1
4
5
  minInstanceCount: 1
@@ -7,5 +8,4 @@ minInstanceCount: 1
7
8
  cloudwatchDashboardDisabled: true
8
9
 
9
10
  openTelemetry:
10
- datadogEnvironmentName: development
11
- enabled: false
11
+ enabled: true
@@ -1,8 +1,8 @@
1
- environment: prod
1
+ deployment: prod
2
+ env: production
2
3
 
3
4
  maxInstanceCount: 10
4
5
  minInstanceCount: 3
5
6
 
6
7
  openTelemetry:
7
- datadogEnvironmentName: production
8
- enabled: false
8
+ enabled: true
@@ -1,4 +1,4 @@
1
- # syntax=docker/dockerfile:1.17
1
+ # syntax=docker/dockerfile:1.18
2
2
 
3
3
  FROM public.ecr.aws/docker/library/node:22-alpine AS dev-deps
4
4
 
@@ -29,7 +29,7 @@ It uses the [Koa] middleware framework and common SEEK packages.
29
29
  Resource APIs enable synchronous interactions and serve as the backbone of SEEK's general service architecture.
30
30
 
31
31
  The `koa-rest-api` template is modelled after a hypothetical service for posting and retrieving job advertisements.
32
- It's stubbed out with in-memory [storage](src/storage) which can observed by standing up an environment with multiple instances.
32
+ It's stubbed out with in-memory [storage](src/storage) which can observed by standing up a deployment with multiple instances.
33
33
  Storage is local to each instance, so load balancing across the instances may render a read inconsistent with a previous write.
34
34
  This would be replaced with an external data store in production.
35
35
 
@@ -75,19 +75,19 @@ pnpm start:debug
75
75
 
76
76
  This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).
77
77
 
78
- - Commits to a feature branch can be deployed to the dev environment by unblocking a step in the Buildkite UI
79
- - Commits to the default branch are automatically deployed to the dev and prod environments in sequence
78
+ - Commits to a feature branch can be deployed to the development environment by unblocking a step in the Buildkite UI
79
+ - Commits to the default branch are automatically deployed to the development and production environments in sequence
80
80
 
81
81
  To rapidly roll back a change,
82
82
  retry an individual deployment step from the previous build in Buildkite.
83
- Note that this will introduce drift between the head of the default Git branch and the live environment;
83
+ Note that this will introduce drift between the head of the default Git branch and the live deployment;
84
84
  use with caution and always follow up with a proper revert or fix in Git history.
85
85
 
86
86
  ## Support
87
87
 
88
88
  ### Dev
89
89
 
90
- TODO: add support links for the dev environment.
90
+ TODO: add support links for the dev deployment.
91
91
 
92
92
  <!--
93
93
  - CloudWatch dashboard
@@ -97,7 +97,7 @@ TODO: add support links for the dev environment.
97
97
 
98
98
  ### Prod
99
99
 
100
- TODO: add support links for the prod environment.
100
+ TODO: add support links for the prod deployment.
101
101
 
102
102
  <!--
103
103
  - CloudWatch dashboard
@@ -9,10 +9,14 @@ owner: '{{values "owner"}}'
9
9
  image: '{{values "image"}}'
10
10
 
11
11
  env:
12
- ENVIRONMENT: '{{values "environment"}}'
13
- OPENTELEMETRY_ENABLED: '{{.Values.openTelemetry.enabled | default false}}'
12
+ DEPLOYMENT: '{{values "deployment"}}'
14
13
  SERVICE: '{{values "service"}}'
15
14
 
15
+ DD_ENV: '{{values "env"}}'
16
+ DD_SERVICE: '{{values "service"}}'
17
+
18
+ OPENTELEMETRY_ENABLED: '{{values "openTelemetry.enabled"}}'
19
+
16
20
  {{if .Values.cloudwatchDashboardDisabled}}
17
21
  cloudwatchDashboardDisabled: {{values "cloudwatchDashboardDisabled"}}
18
22
  {{end}}
@@ -21,9 +25,17 @@ cloudwatchDashboardDisabled: {{values "cloudwatchDashboardDisabled"}}
21
25
  datadogSecretId: '{{values "datadogSecretId"}}'
22
26
  {{end}}
23
27
 
28
+ # Uncomment if the `tin` tier is acceptable for your SEEK Auth Sidecar logs
29
+ # The eeeoh log forwarder bypasses Amazon CloudWatch for cost savings
30
+ # logSink:
31
+ # forwarder: eeeoh
32
+ # splunkIndex: '{{values "logSink.splunkIndex"}}'
33
+
24
34
  openTelemetry:
25
- datadogEnvironmentName: '{{values "openTelemetry.datadogEnvironmentName"}}'
35
+ datadogEnvironmentName: '{{values "env"}}'
26
36
  enabled: {{values "openTelemetry.enabled"}}
37
+ useGantryServiceName: true
38
+
27
39
  {{if .Values.pagerDutyEndpoint}}
28
40
  pagerDutyEndpoint: '{{values "pagerDutyEndpoint"}}'
29
41
  {{end}}
@@ -20,22 +20,22 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@koa/bodyparser": "^6.0.0",
23
- "@koa/router": "^13.0.0",
23
+ "@koa/router": "^14.0.0",
24
24
  "@opentelemetry/api": "^1.9.0",
25
25
  "@opentelemetry/core": "^2.0.0",
26
- "@opentelemetry/exporter-trace-otlp-grpc": "^0.203.0",
27
- "@opentelemetry/instrumentation-aws-sdk": "^0.56.0",
28
- "@opentelemetry/instrumentation-http": "^0.203.0",
26
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.204.0",
27
+ "@opentelemetry/instrumentation-aws-sdk": "^0.58.0",
28
+ "@opentelemetry/instrumentation-http": "^0.204.0",
29
29
  "@opentelemetry/propagator-b3": "^2.0.0",
30
- "@opentelemetry/sdk-node": "^0.203.0",
31
- "@seek/logger": "^10.0.0",
32
- "hot-shots": "^10.0.0",
30
+ "@opentelemetry/sdk-node": "^0.204.0",
31
+ "@seek/logger": "^11.1.0",
32
+ "hot-shots": "^11.0.0",
33
33
  "koa": "^3.0.1",
34
34
  "koa-compose": "^4.1.0",
35
- "seek-datadog-custom-metrics": "^4.6.3",
35
+ "seek-datadog-custom-metrics": "^6.0.0",
36
36
  "seek-koala": "^7.1.0",
37
37
  "skuba-dive": "^2.0.0",
38
- "zod": "^3.25.67"
38
+ "zod": "^4.0.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/chance": "^1.1.3",
@@ -45,12 +45,11 @@
45
45
  "@types/node": "^22.13.10",
46
46
  "@types/supertest": "^6.0.0",
47
47
  "chance": "^1.1.8",
48
- "mime": "^4.0.1",
49
48
  "pino-pretty": "^13.0.0",
50
49
  "skuba": "*",
51
50
  "supertest": "^7.0.0"
52
51
  },
53
- "packageManager": "pnpm@10.12.4",
52
+ "packageManager": "pnpm@10.15.1",
54
53
  "engines": {
55
54
  "node": ">=22"
56
55
  }
@@ -2,7 +2,7 @@
2
2
  * Run `skuba configure` to finish templating and remove this file.
3
3
  */
4
4
 
5
- module.exports = {
5
+ export default {
6
6
  entryPoint: 'src/app.ts',
7
7
  fields: [
8
8
  {
@@ -3,8 +3,8 @@ import type { Middleware } from '#src/types/koa.js';
3
3
  /**
4
4
  * Signifies that the API is available to serve requests.
5
5
  *
6
- * The deployment environment calls this endpoint to see if the container is
7
- * unhealthy and needs to be recycled.
6
+ * The workload hosting environment calls this endpoint to see if the container
7
+ * is unhealthy and needs to be recycled.
8
8
  */
9
9
  export const healthCheckHandler: Middleware = (ctx) => {
10
10
  ctx.state.skipRequestLogging = true;
@@ -1,7 +1,7 @@
1
1
  import { Env } from 'skuba-dive';
2
2
 
3
3
  interface Config {
4
- environment: Environment;
4
+ deployment: Deployment;
5
5
 
6
6
  logLevel: string;
7
7
  name: string;
@@ -11,17 +11,17 @@ interface Config {
11
11
  port: number | null;
12
12
  }
13
13
 
14
- type Environment = (typeof environments)[number];
14
+ type Deployment = (typeof deployments)[number];
15
15
 
16
16
  const dev = '<%- devGantryEnvironmentName %>';
17
17
  const prod = '<%- prodGantryEnvironmentName %>';
18
18
 
19
- const environments = ['local', 'test', dev, prod] as const;
19
+ const deployments = ['local', 'test', dev, prod] as const;
20
20
 
21
- const environment = Env.oneOf(environments)('ENVIRONMENT');
21
+ const deployment = Env.oneOf(deployments)('DEPLOYMENT');
22
22
 
23
23
  /* istanbul ignore next: config verification makes more sense in a smoke test */
24
- const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
24
+ const configs: Record<Deployment, () => Omit<Config, 'deployment'>> = {
25
25
  local: () => ({
26
26
  logLevel: 'debug',
27
27
  name: '<%- serviceName %>',
@@ -62,6 +62,6 @@ const configs: Record<Environment, () => Omit<Config, 'environment'>> = {
62
62
  };
63
63
 
64
64
  export const config: Config = {
65
- ...configs[environment](),
66
- environment,
65
+ ...configs[deployment](),
66
+ deployment,
67
67
  };
@@ -1,4 +1,4 @@
1
- import createLogger, { createDestination } from '@seek/logger';
1
+ import { createDestination, createLogger } from '@seek/logger';
2
2
  import { RequestLogging } from 'seek-koala';
3
3
 
4
4
  import { config } from '#src/config.js';
@@ -9,26 +9,30 @@ const { createContextMiddleware, mixin } =
9
9
  export const contextMiddleware = createContextMiddleware();
10
10
 
11
11
  const { destination, stdoutMock } = createDestination({
12
- mock: config.environment === 'test',
12
+ mock: config.deployment === 'test',
13
13
  });
14
14
 
15
15
  export { stdoutMock };
16
16
 
17
17
  export const logger = createLogger(
18
18
  {
19
- base: {
20
- environment: config.environment,
21
- version: config.version,
19
+ eeeoh: {
20
+ /**
21
+ * TODO: choose an appropriate Datadog log tier.
22
+ *
23
+ * https://github.com/seek-oss/logger/blob/master/docs/eeeoh.md#datadog-log-tiers
24
+ */
25
+ datadog: 'tin',
26
+ team: '<%- teamName %>',
27
+ use: 'environment',
22
28
  },
23
29
 
24
30
  mixin,
25
31
 
26
32
  level: config.logLevel,
27
33
 
28
- name: config.name,
29
-
30
34
  transport:
31
- config.environment === 'local' ? { target: 'pino-pretty' } : undefined,
35
+ config.deployment === 'local' ? { target: 'pino-pretty' } : undefined,
32
36
  },
33
37
  destination,
34
38
  );
@@ -7,5 +7,5 @@ import { config } from '#src/config.js';
7
7
 
8
8
  /* istanbul ignore next: StatsD client is not our responsibility */
9
9
  export const metricsClient = createStatsDClient(StatsD, config, (err) =>
10
- logger.error({ err }, 'StatsD error'),
10
+ logger.error(err, 'StatsD error'),
11
11
  );
@@ -32,7 +32,6 @@ describe('createApp', () => {
32
32
 
33
33
  expect(stdoutMock.calls).toHaveLength(0);
34
34
 
35
- metricsClient.expectTagSubset(['env:test', 'version:test']);
36
35
  metricsClient.expectTagSubset([
37
36
  'http_method:get',
38
37
  'http_status:200',
@@ -133,7 +132,7 @@ describe('createApp', () => {
133
132
 
134
133
  expect(stdoutMock.calls).toMatchObject([
135
134
  {
136
- err: {
135
+ error: {
137
136
  statusCode: 400,
138
137
  type: 'BadRequestError',
139
138
  },
@@ -167,7 +166,7 @@ describe('createApp', () => {
167
166
 
168
167
  expect(stdoutMock.calls).toMatchObject([
169
168
  {
170
- err: {
169
+ error: {
171
170
  statusCode: 500,
172
171
  type: 'InternalServerError',
173
172
  },
@@ -203,7 +202,7 @@ describe('createApp', () => {
203
202
 
204
203
  expect(stdoutMock.calls).toMatchObject([
205
204
  {
206
- err: {
205
+ error: {
207
206
  message: err.message,
208
207
  type: 'Error',
209
208
  },
@@ -237,7 +236,7 @@ describe('createApp', () => {
237
236
 
238
237
  expect(stdoutMock.calls).toMatchObject([
239
238
  {
240
- err: null,
239
+ error: null,
241
240
  level: 50,
242
241
  method: 'GET',
243
242
  msg: 'Server error',
@@ -256,10 +255,10 @@ describe('createApp', () => {
256
255
  });
257
256
 
258
257
  it('handles string error', async () => {
259
- const err = chance.sentence();
258
+ const error = chance.sentence();
260
259
 
261
260
  middleware.mockImplementation(() => {
262
- throw err;
261
+ throw error;
263
262
  });
264
263
 
265
264
  await agent
@@ -270,7 +269,7 @@ describe('createApp', () => {
270
269
 
271
270
  expect(stdoutMock.calls).toMatchObject([
272
271
  {
273
- err,
272
+ error,
274
273
  level: 50,
275
274
  method: 'GET',
276
275
  msg: 'Server error',
@@ -30,10 +30,7 @@ const requestLogging = RequestLogging.createMiddleware((ctx, fields, err) => {
30
30
  : logger.error(fields, 'Server error');
31
31
  });
32
32
 
33
- const version = VersionMiddleware.create({
34
- name: config.name,
35
- version: config.version,
36
- });
33
+ const version = VersionMiddleware.create(config);
37
34
 
38
35
  export const createApp = <State, Context>(
39
36
  ...middleware: Array<Koa.Middleware<State, Context>>
@@ -20,3 +20,9 @@ const listener = app.listen(config.port, () => {
20
20
  // https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
21
21
  // AWS recommends setting an application timeout larger than the load balancer
22
22
  listener.keepAliveTimeout = 31000;
23
+
24
+ // Report unhandled rejections instead of crashing the process
25
+ // Make sure to monitor these reports and alert as appropriate
26
+ process.on('unhandledRejection', (err) =>
27
+ logger.error(err, 'Unhandled promise rejection'),
28
+ );
@@ -81,7 +81,9 @@ steps:
81
81
  agents:
82
82
  queue: <%- devBuildkiteQueueName %>
83
83
  env:
84
- ENVIRONMENT: dev
84
+ DD_DEPLOYMENT_ENVIRONMENT: development
85
+ DD_DEPLOYMENT_SERVICE: <%- serviceName %>
86
+ DEPLOYMENT: dev
85
87
  GET_NPM_TOKEN: please
86
88
  label: 🤞 Deploy Dev
87
89
  concurrency_group: '<%- repoName %>/deploy/dev'
@@ -89,7 +91,9 @@ steps:
89
91
 
90
92
  - <<: *deploy
91
93
  env:
92
- ENVIRONMENT: prod
94
+ DD_DEPLOYMENT_ENVIRONMENT: production
95
+ DD_DEPLOYMENT_SERVICE: <%- serviceName %>
96
+ DEPLOYMENT: prod
93
97
  GET_NPM_TOKEN: please
94
98
  label: 🚀 Deploy Prod
95
99
  branches: ${BUILDKITE_PIPELINE_DEFAULT_BRANCH}
@@ -1 +1 @@
1
- ENVIRONMENT=local
1
+ DEPLOYMENT=local
@@ -1,4 +1,4 @@
1
- # syntax=docker/dockerfile:1.17
1
+ # syntax=docker/dockerfile:1.18
2
2
 
3
3
  FROM public.ecr.aws/docker/library/node:22-alpine AS dev-deps
4
4
 
@@ -54,7 +54,7 @@ pnpm test
54
54
  awsauth
55
55
 
56
56
  # Run smoke test against deployed application
57
- ENVIRONMENT=dev pnpm smoke
57
+ DEPLOYMENT=dev pnpm smoke
58
58
  ```
59
59
 
60
60
  ### Lint
@@ -88,8 +88,8 @@ curl --data '[{}, {"awsRequestId": "local"}]' --include localhost:<%- port %>
88
88
 
89
89
  This project is deployed through a [Buildkite pipeline](.buildkite/pipeline.yml).
90
90
 
91
- - Commits to a feature branch can be deployed to the dev environment by unblocking a step in the Buildkite UI
92
- - Commits to the default branch are automatically deployed to the dev and prod environments in sequence
91
+ - Commits to a feature branch can be deployed to the development environment by unblocking a step in the Buildkite UI
92
+ - Commits to the default branch are automatically deployed to the development and production environments in sequence
93
93
 
94
94
  To deploy locally:
95
95
 
@@ -97,7 +97,7 @@ To deploy locally:
97
97
  # Authenticate to dev account
98
98
  awsauth
99
99
 
100
- ENVIRONMENT=dev pnpm run deploy
100
+ DEPLOYMENT=dev pnpm run deploy
101
101
  ```
102
102
 
103
103
  A hotswap deploy enables faster deployment but come with caveats such as requiring a Lambda to be rebuilt with every build.
@@ -108,19 +108,19 @@ To deploy a [hotswap]:
108
108
  # Authenticate to dev account
109
109
  awsauth
110
110
 
111
- ENVIRONMENT=dev pnpm run deploy:hotswap
111
+ DEPLOYMENT=dev pnpm run deploy:hotswap
112
112
  ```
113
113
 
114
114
  To rapidly roll back a change,
115
115
  retry an individual deployment step from the previous build in Buildkite.
116
- Note that this will introduce drift between the head of the default Git branch and the live environment;
116
+ Note that this will introduce drift between the head of the default Git branch and the live deployment;
117
117
  use with caution and always follow up with a proper revert or fix in Git history.
118
118
 
119
119
  ## Support
120
120
 
121
121
  ### Dev
122
122
 
123
- TODO: add support links for the dev environment.
123
+ TODO: add support links for the dev deployment.
124
124
 
125
125
  <!--
126
126
  - CloudWatch dashboard
@@ -130,7 +130,7 @@ TODO: add support links for the dev environment.
130
130
 
131
131
  ### Prod
132
132
 
133
- TODO: add support links for the prod environment.
133
+ TODO: add support links for the prod deployment.
134
134
 
135
135
  <!--
136
136
  - CloudWatch dashboard