2.0.2 • Published 5 years ago

lamb-rest-api v2.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Lamb-rest-api

About

Mapping handler lambda function request to rest API request.

Example

  • serverless.yml
...
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          method: GET
          path: hello
  
...
  • routes.ts
import { Router, Application } from 'lamb-rest-api';

const routes = new Router();
routes.get('/hello', (app: Application) => {
  return {
    httpStatus: 200,
    body: JSON.stringify({
      event: app.event,
    }, null, 2);
  }
});

export default {
  routes,
}
  • handler.ts
import { APIGatewayProxyHandler } from 'aws-lambda';
import { LambRestAPI } from 'lamb-rest-api';
import { routes } from './routes.ts';
import 'source-map-support/register';

export const hello: APIGatewayProxyHandler = LambRestAPI.handler({
  routes,
});

Custom Application

  • application-builder.ts
import { Application } from 'lamb-rest-api';

class MyApplication extends Application {
  constructor(event, context, callback) {
    super(event, context, callback);
  }

  public contextBuilder() {
    // custom your data
    const event$ = this.event;
    const context$ = this.context;
    // ...
  }
}
  • handler.ts
import { MyApplication } from './application-builder.ts';

export const hello: APIGatewayProxyHandler = LambRestAPI.handler({
  application: MyApplication,
});
2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.2.4

5 years ago

1.2.4-beta5

5 years ago

1.2.4-beta4

5 years ago

1.2.4-beta3

5 years ago

1.2.4-beta2

5 years ago

1.2.4-beta

5 years ago

1.2.3

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago