@tsed/platform-aws

Module to support AWS function with Ts.ED

Usage no npm install needed!

<script type="module">
  import tsedPlatformAws from 'https://cdn.skypack.dev/@tsed/platform-aws';
</script>

README

Ts.ED logo

Platform AWS

Build & Release PR Welcome Coverage Status npm version semantic-release code style: prettier backers

Website   •   Getting started   •   Slack   •   Twitter

IMPORTANT: This package is deprecated in favor of @tsed/platform-serverless-http or @tsed/platform-serverless. Please don't use this package for new project!

A package of Ts.ED framework. See website: https://tsed.io/tutorials/aws.html

Installation

Run npm command (or yarn):

npm install --save @tsed/platform-aws

Usage

Create a new LambdaServer.ts in src directory:

import {PlatformAws} from "@tsed/platform-aws";
import "@tsed/platform-express" 
// or import "@tsed/platform-koa"

PlatformAws.bootstrap(Server, {
 aws: {
   binaryMimeTypes: [ // optional
     // mime types list 
   ]
 },
 // additional Ts.ED options. See https://tsed.io/tutorials/aws.html
});

// Handler used by AWS
export const handler = PlatformAws.callback();

Then create lambda.js on your root project:

module.exports = require("./dist/LambdaServer.js");

This file will be used by AWS to forward request to your application.

Finally, package and create your Lambda function, then configure a simple proxy API using Amazon API Gateway and integrate it with your Lambda function.

See more details on aws-serveless-express project.

Getting the API Gateway event object

This package includes decorators to easily get the event object Lambda received from API Gateway:

import {Controller, Get} from "@tsed/common"; 
import {AwsEvent, AwsContext} from "@tsed/platform-aws"; 

@Controller('/')
class MyCtrl {
 @Get('/')
 get(@AwsEvent() event: any, @AwsContext() context: any) {
   console.log("Event", apiGateway.event);
   console.log("Context", apiGateway.context);
   
   return apiGateway;
 }
}

Contributors

Please read contributing guidelines here

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

The MIT License (MIT)

Copyright (c) 2016 - 2018 Romain Lenzotti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.