Skip to content

Commit 93d2333

Browse files
committed
treat cdk examples as any other modules
1 parent c0b0746 commit 93d2333

21 files changed

+6861
-17229
lines changed

examples/cdk/bin/cdk-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
4-
import { CdkAppStack } from '../lib/example-stack';
4+
import { CdkAppStack } from '../src/example-stack';
55

66
const app = new cdk.App();
77
new CdkAppStack(app, 'CdkAppStack', {});

examples/cdk/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
roots: ['<rootDir>/test'],
4-
testMatch: ['**/*.test.ts'],
3+
roots: ['<rootDir>/tests'],
4+
testMatch: ['**/*.tests.ts'],
55
transform: {
66
'^.+\\.tsx?$': 'ts-jest'
77
}

examples/cdk/package-lock.json

Lines changed: 6806 additions & 17177 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "cdk-app",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"bin": {
55
"cdk-app": "bin/cdk-app.js"
66
},
77
"scripts": {
88
"build": "tsc --skipLibCheck",
99
"watch": "tsc -w",
10-
"test": "jest",
10+
"test": "jest --passWithNoTests",
1111
"cdk": "cdk"
1212
},
1313
"devDependencies": {

examples/cdk/lib/example-function.MyFunctionWithMiddy.ts renamed to examples/cdk/src/example-function.MyFunctionWithMiddy.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const metrics = new Metrics({ namespace: namespace, serviceName: serviceName });
1212
const logger = new Logger({ logLevel: 'INFO', serviceName: serviceName });
1313
const tracer = new Tracer({ serviceName: serviceName });
1414

15-
const lambdaHandler = async (event: typeof Events.Custom.CustomEvent, context: Context) => {
15+
const lambdaHandler = async (event: typeof Events.Custom.CustomEvent, context: Context): Promise<unknown> => {
1616
// ### Experiment with Logger
1717
// AWS Lambda context is automatically injected by the middleware
1818

@@ -32,7 +32,7 @@ const lambdaHandler = async (event: typeof Events.Custom.CustomEvent, context: C
3232
const metricWithItsOwnDimensions = metrics.singleMetric();
3333
metricWithItsOwnDimensions.addDimension('InnerDimension', 'true');
3434
metricWithItsOwnDimensions.addMetric('single-metric', MetricUnits.Percent, 50);
35-
35+
3636
// ### Experiment with Tracer
3737

3838
// Service & Cold Start annotations will be added for you by the decorator/middleware
@@ -58,16 +58,18 @@ const lambdaHandler = async (event: typeof Events.Custom.CustomEvent, context: C
5858
tracer.setSegment(handlerSegment);
5959
// The main segment (facade) will be closed for you at the end by the decorator/middleware
6060
}
61-
61+
6262
return res;
63-
}
63+
};
6464

6565
// We instrument the handler with the various Middy middlewares
6666
export const handler = middy(lambdaHandler)
6767
.use(captureLambdaHandler(tracer))
68-
.use(logMetrics(metrics, {
69-
captureColdStartMetric: true,
70-
throwOnEmptyMetrics: true,
71-
defaultDimensions: { environment: 'example', type: 'withDecorator' },
72-
}))
73-
.use(injectLambdaContext(logger));
68+
.use(
69+
logMetrics(metrics, {
70+
captureColdStartMetric: true,
71+
throwOnEmptyMetrics: true,
72+
defaultDimensions: { environment: 'example', type: 'withDecorator' },
73+
})
74+
)
75+
.use(injectLambdaContext(logger));

0 commit comments

Comments
 (0)