-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(docs): prepare documentation and examples
- Loading branch information
1 parent
3c7fa2f
commit 27b8a73
Showing
18 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out | ||
.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# [aws-lambda-nodejs-esbuild](../../README.md) complete example | ||
|
||
This example shows how to use the `aws-lambda-nodejs-esbuild` construct in the most common way. | ||
|
||
Any package set as `external` in the `esbuildOptions` will not be bundled into the output file, but packed as a `node_modules` dependency. | ||
|
||
If packing a package is not required, for instance if it exists in a layer, you may set it in the option `exclude`, so it will neither be packed nor bundled. `aws-sdk` is excluded by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"app": "npx ts-node stack/app.ts", | ||
"versionReporting": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "complete", | ||
"version": "0.1.0", | ||
"devDependencies": { | ||
"@aws-cdk/aws-lambda": "^1.70.0", | ||
"@aws-cdk/core": "^1.70.0", | ||
"@types/node": "10.17.27", | ||
"aws-cdk": "1.70.0", | ||
"aws-lambda-nodejs-esbuild": "*", | ||
"ts-node": "^8.1.0", | ||
"typescript": "~3.9.7" | ||
}, | ||
"dependencies": { | ||
"isin-validator": "^1.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import validateIsin from 'isin-validator'; | ||
|
||
export function handler(event: any) { | ||
const isInvalid = validateIsin(event); | ||
|
||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: isInvalid ? 'ISIN is invalid!' : 'ISIN is fine!', | ||
input: event, | ||
}), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as cdk from '@aws-cdk/core'; | ||
import { CompleteStack } from './stack'; | ||
|
||
const app = new cdk.App(); | ||
new CompleteStack(app, 'CompleteStack'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as cdk from '@aws-cdk/core'; | ||
import { NodejsFunction } from 'aws-lambda-nodejs-esbuild'; | ||
|
||
export class CompleteStack extends cdk.Stack { | ||
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
|
||
new NodejsFunction(this, 'CompleteExampleFunction', { | ||
handler: 'src/index.handler', | ||
esbuildOptions: { | ||
external: ['isin-validator'] | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "commonjs", | ||
"lib": ["es2018"], | ||
"declaration": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"experimentalDecorators": true, | ||
"strictPropertyInitialization": false, | ||
"typeRoots": ["./node_modules/@types"] | ||
}, | ||
"exclude": ["cdk.out"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out | ||
.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# [aws-lambda-nodejs-esbuild](../../README.md) minimal example | ||
|
||
This example shows how to use the `aws-lambda-nodejs-esbuild` construct with default options. | ||
|
||
If you do not provide a `handler` option it assumes that you define a lambda handler as `index.js` file in root folder. | ||
|
||
By default it bundles all dependencies in a single file and transpiles to the `ES2017` target. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"app": "node stack/app.js", | ||
"versionReporting": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const validateIsin = require('isin-validator'); | ||
|
||
module.exports.handler = (event) => { | ||
const isInvalid = validateIsin(event); | ||
|
||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: isInvalid ? 'ISIN is invalid!' : 'ISIN is fine!', | ||
input: event, | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "minimal", | ||
"version": "0.1.0", | ||
"devDependencies": { | ||
"@aws-cdk/aws-lambda": "^1.70.0", | ||
"@aws-cdk/core": "1.70.0", | ||
"aws-cdk": "1.70.0", | ||
"aws-lambda-nodejs-esbuild": "*" | ||
}, | ||
"dependencies": { | ||
"isin-validator": "^1.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const cdk = require('@aws-cdk/core'); | ||
const { MinimalStack } = require('./stack'); | ||
|
||
const app = new cdk.App(); | ||
new MinimalStack(app, 'MinimalStack'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const cdk = require('@aws-cdk/core'); | ||
const { NodejsFunction } = require('aws-lambda-nodejs-esbuild'); | ||
|
||
class MinimalStack extends cdk.Stack { | ||
constructor(scope, id, props) { | ||
super(scope, id, props); | ||
|
||
new NodejsFunction(this, 'MinimalExampleFunction'); | ||
} | ||
} | ||
|
||
module.exports = { MinimalStack }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"license": "MIT", | ||
"author": "Victor Korzunin <[email protected]>", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"package.json", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters