Skip to content

Commit

Permalink
[now-node] Add NowApiHandler type (#4001)
Browse files Browse the repository at this point in the history
* add NowApiHandler type

`now` equivalent of `NextApiHandler` introduced vercel/next.js#10573

* chore: add fixture

Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Apr 3, 2020
1 parent 1c47d13 commit 1ceeac4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/now-node/src/types.ts
Expand Up @@ -15,3 +15,8 @@ export type NowResponse = ServerResponse & {
json: (jsonBody: any) => NowResponse;
status: (statusCode: number) => NowResponse;
};

export type NowApiHandler = (
req: NowRequest,
res: NowResponse
) => void;
8 changes: 8 additions & 0 deletions packages/now-node/test/fixtures/15-helpers/ts/handler.ts
@@ -0,0 +1,8 @@
import { NowApiHandler } from './types';

const listener: NowApiHandler = (req, res) => {
res.status(200);
res.send('hello:RANDOMNESS_PLACEHOLDER');
};

export default listener;

0 comments on commit 1ceeac4

Please sign in to comment.