-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: seven <zilisheng1996@gmail.com>
- Loading branch information
Showing
8 changed files
with
318 additions
and
45 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,25 @@ | ||
import { Express } from 'express'; | ||
import Application from 'koa'; | ||
import ServerlessResponse from './serverlessResponse'; | ||
import ServerlessRequest from './serverlessRequest'; | ||
|
||
// eslint-disable-next-line | ||
const callableFn = (callback: (req: any, res: any) => Promise<void>) => { | ||
return async (request: ServerlessRequest) => { | ||
const response = new ServerlessResponse(request); | ||
|
||
callback(request, response); | ||
|
||
return response; | ||
}; | ||
}; | ||
|
||
export const constructFramework = (app: Express | Application) => { | ||
if (app instanceof Application) { | ||
return callableFn(app.callback()); | ||
} else if (typeof app === 'function') { | ||
return callableFn(app); | ||
} else { | ||
throw new Error(`Unsupported framework ${app}`); | ||
} | ||
}; |
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