-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from ianbytchek/master
Update typescript definitions file and improve the pre-test
- Loading branch information
Showing
3 changed files
with
33 additions
and
25 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,26 1,34 @@ | ||
/// <reference types="aws-lambda" /> | ||
|
||
declare namespace ServerlessHttp { | ||
type FrameworkApplication = { | ||
callback: Function; | ||
handle: Function; | ||
router: { | ||
route: Function; | ||
} | ||
_core: { | ||
_dispatch: Function; | ||
} | ||
export interface FrameworkApplication { | ||
callback: Function; | ||
handle: Function; | ||
router: { | ||
route: Function; | ||
} | ||
type HandlerCompatibleApp = Function | Partial<FrameworkApplication>; | ||
type LambdaPartial = ( | ||
event: AWSLambda.APIGatewayProxyEvent, | ||
context: AWSLambda.Context | ||
) => AWSLambda.APIGatewayProxyResult; | ||
_core: { | ||
_dispatch: Function; | ||
} | ||
} | ||
|
||
/** | ||
* Handler-compatible function or application. | ||
*/ | ||
export type Application = Function | Partial<FrameworkApplication>; | ||
|
||
/** | ||
* AWS Lambda APIGatewayProxyHandler-like handler. | ||
*/ | ||
export type Handler = ( | ||
event: AWSLambda.APIGatewayProxyEvent, | ||
context: AWSLambda.Context | ||
) => Promise<AWSLambda.APIGatewayProxyResult>; | ||
} | ||
|
||
declare function serverlessHttp( | ||
app: ServerlessHttp.HandlerCompatibleApp, | ||
opts?: any | ||
): Promise<ServerlessHttp.LambdaPartial>; | ||
/** | ||
* Wraps the application into a Lambda APIGatewayProxyHandler-like handler. | ||
*/ | ||
declare function ServerlessHttp(application: ServerlessHttp.Application, options?: any): ServerlessHttp.Handler; | ||
|
||
export = serverlessHttp; | ||
export = ServerlessHttp; |
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,6 1,6 @@ | ||
import serverlessHttp = require('..'); | ||
import Koa = require('koa'); | ||
import Koa = require("koa"); | ||
import serverlessHttp = require(".."); | ||
|
||
// Simple typescript sanity check | ||
serverlessHttp(() => { }); | ||
serverlessHttp(new Koa()); | ||
// Basic definitions check. | ||
const handlerWithFn: serverlessHttp.Handler = serverlessHttp(() => { }); | ||
const handlerWithApp: serverlessHttp.Handler = serverlessHttp(new Koa()); |