-
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.
Merge pull request #1 from geek-fun/feat/enable-koa-support
feat: setup test for koa application
- Loading branch information
Showing
12 changed files
with
1,470 additions
and
54 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 was deleted.
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
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
File renamed without changes.
Oops, something went wrong.