hoangvvo / next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2
https://www.npmjs.com/package/next-connect
MIT License
1.63k stars 65 forks source link

Make NextConnect compatible with NextApiHandler #128

Closed slaypni closed 3 years ago

slaypni commented 3 years ago

The following code was causing TS error because NextConnect was not compatible with NextApiHandler. It can be problematic when passing handler to functions which take NextApiHandler. This PR is to fix the issue.

import { NextApiRequest, NextApiResponse, NextApiHandler } from "next";
import nc, { NextConnect } from "next-connect";

// TS Error because NextConnect is not compatible with NextApiHandler
const handler: NextApiHandler = nc<NextApiRequest, NextApiResponse>();
changeset-bot[bot] commented 3 years ago

⚠️ No Changeset found

Latest commit: 7aef5f3cba65183e0ecde6744c217129c4fc131f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

codecov[bot] commented 3 years ago

Codecov Report

Merging #128 (7aef5f3) into master (40df2ef) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #128   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           83        83           
=========================================
  Hits            83        83           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 40df2ef...7aef5f3. Read the comment docs.

hoangvvo commented 3 years ago

Thanks 👍