Last active
June 11, 2019 11:33
-
-
Save buggy/a6c724028baa1b47450868f9f1937ef7 to your computer and use it in GitHub Desktop.
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
import 'source-map-support/register' | |
import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from "aws-lambda"; | |
let response; | |
export async function lambdaHandler(event: APIGatewayProxyEvent, context: Context): Promise<APIGatewayProxyResult> { | |
try { | |
// const ret = await axios(url); | |
response = { | |
'statusCode': 200, | |
'body': JSON.stringify({ | |
message: 'hello world', | |
// location: ret.data.trim() | |
}) | |
} | |
throw new Error("zzz"); | |
} catch (err) { | |
console.log(err); | |
return err; | |
} | |
return response | |
}; |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Orig", | |
"type": "node", | |
"request": "attach", | |
"address": "localhost", | |
"port": 5858, | |
// From the sam init example, it would be "${workspaceRoot}/hello_world" | |
"localRoot": "${workspaceRoot}/hello-world", | |
"remoteRoot": "/var/task", | |
"protocol": "inspector", | |
"stopOnEntry": false, | |
"sourceMapPathOverrides": { | |
"webpack:///./~/*": "${workspaceRoot}/hello-world/node_modules/*", | |
"webpack:///./*": "${workspaceRoot}/hello-world/*", | |
"webpack:///*": "*" | |
} | |
} | |
] | |
} |
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
{ | |
"name": "hello_world", | |
"version": "1.0.0", | |
"description": "hello world sample for NodeJS", | |
"main": "app.js", | |
"repository": "https://github.com/awslabs/aws-sam-cli/tree/develop/samcli/local/init/templates/cookiecutter-aws-sam-hello-nodejs", | |
"author": "SAM CLI", | |
"license": "MIT", | |
"dependencies": { | |
"axios": "^0.18.0", | |
"source-map-support": "^0.5.12" | |
}, | |
"scripts": { | |
"tsc": "rimraf build && tsc -p tsconfig.json", | |
"webpack": "webpack-cli src/app.ts -c webpack.config.js -o build/app.js", | |
"webpack:watch": "webpack-cli src/app.ts -c webpack.config.js -o build/app.js -w", | |
"test": "jest" | |
}, | |
"devDependencies": { | |
"@babel/core": "^7.4.5", | |
"@babel/preset-env": "^7.4.5", | |
"@types/aws-lambda": "^8.10.27", | |
"@types/jest": "^24.0.13", | |
"babel-loader": "^8.0.6", | |
"jest": "^24.8.0", | |
"rimraf": "^2.6.3", | |
"ts-jest": "^24.0.2", | |
"ts-loader": "^6.0.2", | |
"typescript": "^3.5.1", | |
"webpack": "^4.33.0", | |
"webpack-cli": "^3.3.3" | |
} | |
} |
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
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: > | |
js-test | |
Sample SAM Template for js-test | |
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst | |
Globals: | |
Function: | |
Timeout: 3 | |
Resources: | |
HelloWorldFunction: | |
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction | |
Properties: | |
CodeUri: hello-world | |
Handler: build/app.lambdaHandler | |
Runtime: nodejs8.10 | |
Events: | |
HelloWorld: | |
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api | |
Properties: | |
Path: /hello | |
Method: get | |
Outputs: | |
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function | |
# Find out more about other implicit resources you can reference within SAM | |
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api | |
HelloWorldApi: | |
Description: "API Gateway endpoint URL for Prod stage for Hello World function" | |
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/" | |
HelloWorldFunction: | |
Description: "Hello World Lambda Function ARN" | |
Value: !GetAtt HelloWorldFunction.Arn | |
HelloWorldFunctionIamRole: | |
Description: "Implicit IAM Role created for Hello World function" | |
Value: !GetAtt HelloWorldFunctionRole.Arn |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
"allowJs": true, /* Allow javascript files to be compiled. */ | |
"checkJs": true, /* Report errors in .js files. */ | |
"sourceMap": true, /* Generates corresponding '.map' file. */ | |
"outDir": "./build", /* Redirect output structure to the directory. */ | |
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | |
}, | |
"include": ["src/**/*"] | |
} | |
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
module.exports = { | |
devtool: "source-map", | |
resolve: { | |
extensions: [".js", ".jsx", ".ts", ".tsx"] | |
}, | |
output: { | |
libraryTarget: 'commonjs2' | |
}, | |
target: "node", | |
module: { | |
rules: [ | |
{ | |
test: /\.m?js$/, | |
exclude: /(node_modules|bower_components)/, | |
use: { | |
loader: "babel-loader", | |
options: { | |
presets: ["@babel/preset-env"] | |
} | |
} | |
}, | |
{ | |
test: /\.tsx?$/, | |
loader: "ts-loader" | |
} | |
] | |
}, | |
mode: "development" | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment