@typeix/resty-aws-lambda
TypeScript icon, indicating that this package has built-in type declarations

8.6.0 • Public • Published

Typeix Logo

A progressive Node.js framework for building scalable applications.

@typeix/resty Typescript framework for Node.js

Build Status Coverage Status npm

Starters

  • TBD

Example Usage

import {
  Controller, Inject, ResolvedRoute, 
  GET, POST, OnError, RootModule, Logger, Router
} from "@typeix/resty";
import {lambdaServer} from "@typeix/resty-aws-lambda";

// define controller
@Controller({
  path: "/"
})
class HomeController {

  @Inject()
  private request: IncomingMessage;

  @Inject()
  private response: ServerResponse;

  @ResolvedRoute()
  private route: IResolvedRoute;

  @GET()
  actionGet() {
    return this.route.method.toUpperCase() + " ACTION";
  }

  @POST()
  actionAjax(@RequestBody() body: Buffer) {
    return JSON.stringify(body.toString());
  }

  @OnError("*")
  errorCase() {
    return "FIRE ERROR CASE";
  }

  @GET("redirect")
  actionRedirect() {
    this.response.setHeader("Location", "/mypage");
    this.response.writeHead(307);
    this.response.end();
  }
}

// DEFINE MODULE 
@RootModule({
  imports: [], // here you can import other modules
  shared_providers: [
    {
      provide: Logger,
      useFactory: () => new Logger(Logger.defaultConfig("info"))
    },
    Router
  ],
  providers: [],
  controllers: [HomeController]
})
class ApplicationModule {}

// CREATE SERVER
export const handler = lambdaServer(ApplicationModule);

Package Sidebar

Install

npm i @typeix/resty-aws-lambda

Homepage

typeix.com

Weekly Downloads

0

Version

8.6.0

License

MIT

Unpacked Size

15.3 kB

Total Files

11

Last publish

Collaborators

  • igorzg