Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[now-node] Add NowApiHandler type #4001

Merged
merged 2 commits into from Apr 3, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link
Member

@styfle styfle Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a new file test/fixtures/15-helpers/ts/handler.ts to test this new behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would that be as simple as this?

import { NowApiHandler } from './types';

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

export default listener;