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.64k stars 65 forks source link

Export the options interface #152

Closed smitssjors closed 3 years ago

smitssjors commented 3 years ago

This allows for writing a wrapper around the factory function to e.g. always pass the NextApiRequest and NextApiResponse generics to the factory function. I am now unable to type the options object which I would like to pass to the factory function. Example:

function nextConnectApi<
  T = any,
  Req = NextApiRequest,
  Res = NextApiResponse<T>
>(options?: Options<Req, Res>) {
  return nc<Req, Res>(options);
}
changeset-bot[bot] commented 3 years ago

⚠️ No Changeset found

Latest commit: ac9fb2e18c1a96a0b63664e98d1b41a2607b0626

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 #152 (ac9fb2e) into master (2b81d76) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #152   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           80        80           
=========================================
  Hits            80        80           

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 2b81d76...ac9fb2e. Read the comment docs.

smitssjors commented 3 years ago

I know that you can still import Options even though it is not exported but exporting it is semantically correct and it offers better editor support.

hoangvvo commented 3 years ago

lgtm thanks