-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
700 additions
and
130 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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import {PlatformExpress} from "@tsed/platform-express"; | ||
import {PlatformAws} from "@tsed/platform-aws"; | ||
import "@tsed/platform-express"; | ||
import {Server} from "./Server"; | ||
|
||
const awsServerlessExpress = require("aws-serverless-express"); | ||
// or import "@tsed/platform-koa"; | ||
|
||
// The function handler to setup on AWS Lambda console -- the name of this function must match the one configured on AWS | ||
export const handler = async (event: any, context: any) => { | ||
const platform = await PlatformExpress.bootstrap(Server); | ||
const lambdaServer = awsServerlessExpress.createServer(platform.app.callback()); | ||
PlatformAws.bootstrap(Server, { | ||
aws: { | ||
binaryMimeTypes: [ // optional | ||
// mime types list | ||
] | ||
}, | ||
// additional Ts.ED options. See https://tsed.io/tutorials/aws.html | ||
}); | ||
|
||
return awsServerlessExpress.proxy(lambdaServer, event, context, "PROMISE").promise; | ||
}; | ||
// Handler used by AWS | ||
export const handler = PlatformAws.callback(); |
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 |
---|---|---|
@@ -1,35 +1,11 @@ | ||
import {PlatformExpress} from "@tsed/platform-express"; | ||
import * as awsServerlessExpress from "aws-serverless-express"; | ||
import {PlatformAws} from "@tsed/platform-aws"; | ||
import "@tsed/platform-express"; | ||
import {Server} from "./Server"; | ||
|
||
// NOTE: If you get ERR_CONTENT_DECODING_FAILED in your browser, this is likely | ||
// due to a compressed response (e.g. gzip) which has not been handled correctly | ||
// by aws-serverless-express and/or API Gateway. Add the necessary MIME types to | ||
// binaryMimeTypes below, then redeploy (`npm run package-deploy`) | ||
const binaryMimeTypes = [ | ||
"application/javascript", | ||
"application/json", | ||
"application/octet-stream", | ||
"application/xml", | ||
"font/eot", | ||
"font/opentype", | ||
"font/otf", | ||
"image/jpeg", | ||
"image/png", | ||
"image/svg+xml", | ||
"text/comma-separated-values", | ||
"text/css", | ||
"text/html", | ||
"text/javascript", | ||
"text/plain", | ||
"text/text", | ||
"text/xml" | ||
]; | ||
PlatformAws.bootstrap(Server, { | ||
aws: {} | ||
// additional Ts.ED options. See https://tsed.io/tutorials/aws.html | ||
}); | ||
|
||
// The function handler to setup on AWS Lambda console -- the name of this function must match the one configured on AWS | ||
export async function awsHanlder(event: any, context: any) { | ||
const platform = await PlatformExpress.bootstrap(Server); | ||
const lambdaServer = awsServerlessExpress.createServer(platform.app.callback(), null, binaryMimeTypes); | ||
|
||
return awsServerlessExpress.proxy(lambdaServer, event, context, "PROMISE").promise; | ||
} | ||
// Handler used by AWS | ||
export const handler = PlatformAws.callback(); |
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
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 @@ | ||
src | ||
test | ||
tsconfig.compile.json | ||
tsconfig.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "@tsed/platform-aws", | ||
"version": "6.0.0-beta.5", | ||
"description": "Module to support AWS function with Ts.ED", | ||
"main": "./lib/index.js", | ||
"typings": "./lib/index.d.ts", | ||
"private": false, | ||
"keywords": [ | ||
"aws", | ||
"lambda", | ||
"functions", | ||
"TypeScript", | ||
"typescript", | ||
"Decorator", | ||
"decorators", | ||
"decorator", | ||
"express", | ||
"koa", | ||
"Controller", | ||
"Inject", | ||
"ioc", | ||
"di", | ||
"mvc", | ||
"swagger", | ||
"swagger ui", | ||
"ES2015", | ||
"ES6", | ||
"server", | ||
"rest", | ||
"api", | ||
"validation" | ||
], | ||
"author": { | ||
"name": "Romain Lenzotti" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/TypedProject/tsed/issues" | ||
}, | ||
"homepage": "http://tsed.io/", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TypedProject/tsed.git" | ||
}, | ||
"scripts": { | ||
"build": "tsc --build tsconfig.compile.json" | ||
}, | ||
"devDependencies": { | ||
"@types/aws-serverless-express": "3.3.3", | ||
"@tsed/common": "6.0.0-beta.5", | ||
"@tsed/core": "6.0.0-beta.5", | ||
"@tsed/di": "6.0.0-beta.5", | ||
"aws-serverless-express": "3.3.8", | ||
"aws-serverless-koa": "1.0.1" | ||
}, | ||
"dependencies": { | ||
"aws-serverless-express": "^3.3.8" | ||
} | ||
} |
Oops, something went wrong.