next-connect

The TypeScript-ready, minimal router and middleware layer for Next.js, Micro, Vercel, or Node.js http/http2

MIT License

Downloads
355.5K
Stars
1.6K
Committers
11

Bot releases are hidden (Show)

next-connect - v1.0.0 Latest Release

Published by hoangvvo over 1 year ago

Published v1

next-connect - v1.0.0-next.4

Published by hoangvvo over 1 year ago

next-connect - v1.0.0-next.3

Published by hoangvvo about 2 years ago

What's Changed

Full Changelog: https://github.com/hoangvvo/next-connect/compare/v1.0.0-next.2...v1.0.0-next.3

next-connect - v1.0.0-next.2

Published by hoangvvo over 2 years ago

next-connect - v1.0.0-next.1

Published by hoangvvo over 2 years ago

What's Changed

Full Changelog: https://github.com/hoangvvo/next-connect/compare/v1.0.0-next.0...v1.0.0-next.1

next-connect -

Published by hoangvvo over 2 years ago

This is the rewrite of next-connect. Most APIs may not be backward-compatible.

  • breaking: Drop built-in support for Express.js middleware. You can always create a tiny wrapper function to maintain this functionality. https://github.com/hoangvvo/next-connect#expressjs-compatibility
    • Remove next(err) pattern
  • improvement More straight-forward implementation and avoid patchy solutions. Now the handler will resolve based on pure promise resolution. One should expect a boost in perf as well.
  • feature Async middleware paradigm like Koa
router
  .use(async (req, res, next) => {
    const start = Date.now();
    await next(); // call next in chain
    const end = Date.now();
    console.log(`Request took ${end - start}ms`);
  })
  .use(authy)
  .use(databasey)
  .get(getty)
  .post(posty)
  • feature Forward returned values from handlers
router
  .use(async (req, res, next) => {
    return (await next()) + 1;
  })
  .use(async () => {
    return (await next()) + 2;
  })
  .use(async () => {
    return 3;
  });
console.log(await router.run(req, res));
// The above will print "6"
  • breaking Move to named export to avoid some issues with bundler. We also have full support for ESM/CJS
  • improvement Rewritten in TypeScript
  • fix in handler(), if there is no matching .method() (even if there are matchign .use()`, nothing should be executed.
  • fix onError should also be triggered when throwing in onNoMatch
next-connect - v0.12.1

Published by hoangvvo over 2 years ago

  • breaking: flow change: handle() does not use onError (ad857bedb0996312ad3a5ea966ce3a60417429a6)
  • fix: make sure handler is resolvable (#178)
next-connect -

Published by hoangvvo almost 3 years ago

  • Allow regular expressions to be used for route. (#157)
next-connect -

Published by hoangvvo about 3 years ago

  • Export the options interface (#152)
next-connect -

Published by hoangvvo over 3 years ago

  • Make NextConnect compatible with NextApiHandler (#128)
  • docs(README): fix typo (#123)
  • Mark sideEffects false and update README (21c9c73fe3746e66033fd51e2aa01d479e267ad6)
next-connect -

Published by hoangvvo over 3 years ago

  • Express Router compatibility (#121)
  • Add ESModule export (#122)
next-connect - v0.9.1

Published by hoangvvo almost 4 years ago

  • Deprecate apply() for run() (#108)
next-connect - v0.9.0

Published by hoangvvo about 4 years ago

  • Add all() to match any methods (#105)
next-connect -

Published by hoangvvo over 4 years ago

  • Fix handler return type (#75)
next-connect - v0.8.0

Published by hoangvvo over 4 years ago

  • Fix TypeScript signature and support both API and non-API pages (#70) (Breaking)

This is a breaking change for TS users: See TypeScript section for more info.

next-connect - v0.7.1

Published by hoangvvo over 4 years ago

  • Call trouter#find with pathname (#62) (Fix #53)
next-connect - v0.7.0

Published by hoangvvo over 4 years ago

  • feat: add support for handler generics (#57)
  • Consider base when mounting subapp (#61)
next-connect - v0.6.6

Published by hoangvvo over 4 years ago

  • Fix uncaught error in async middleware (#50)
next-connect - v0.6.5

Published by hoangvvo over 4 years ago

  • Fix uncaught error in non-async functions (#45)
next-connect - v0.6.4

Published by hoangvvo over 4 years ago

Patches

  • Add TypeScript definition (#44)