Skip to content

Conversation

@bitgopatmcl
Copy link
Contributor

@bitgopatmcl bitgopatmcl commented Aug 10, 2022

Initial PR for a lighter weight integration of api-ts specifications with Express. The idea is to provide a relatively unopinionated base layer that provides type-checked requests and is flexible enough for other packages to build off of. This should improve familiarity and DX while simultaneously not reinventing the wheel on much of the functionality the existing router provides.

Goals

  • Define routes in Express that are associated with an api-ts apiSpec
  • Augment the existing Express request with the decoded request object
  • Augment the existing Express response with a type-checked encode function
  • Allow customization of what to do on decode/encode errors, per-route if desired
  • Allow action to be performed after an encoded response is sent, per-route if desired
  • Allow routes to be defined with path that is different than the one specified in the
    httpRoute (e.g. for aliases)
  • Follow the express router api as closely as possible otherwise

Non-Goals

  • Enforce that all routes listed in an apiSpec have an associated route handler
  • Layer anything on top of the express.RequestHandler[] chain beyond the additional
    properties described above (projects and other libraries can do this)

@bitgopatmcl bitgopatmcl force-pushed the typed-express-router branch 7 times, most recently from 14a21dc to 0bcbf80 Compare August 11, 2022 02:24
@bitgopatmcl bitgopatmcl changed the title feat: add initial typed-express-router package feat: add typed-express-router package Aug 11, 2022
@bitgopatmcl bitgopatmcl force-pushed the typed-express-router branch from 0bcbf80 to ccc8437 Compare August 11, 2022 02:47
@bitgopatmcl bitgopatmcl marked this pull request as ready for review August 11, 2022 12:28
@bitgopatmcl bitgopatmcl requested a review from a team as a code owner August 11, 2022 12:28
@bitgopatmcl
Copy link
Contributor Author

Should resolve #135 both with the after-response hook and by not messing with request handler chains. Also should address #189.

Copy link
Contributor

@ericcrosson-bitgo ericcrosson-bitgo left a comment

Choose a reason for hiding this comment

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

The main file index.ts file looks pretty simple, true to the idea of this new package. Thanks for the high test coverage! Plenty of examples of use made it easy to review this code

Looks great to me, I won't merge after approval in case you wanted to manually add a git tag that semantic-release will pick up as an input in calculating the next package version. I think if we don't add a tag it'll pick some beta form of 1.0.0 (but on the beta dist tag, FAQ). I have no idea what happens when we drop out of beta in that case, whether we land on v1 or v2

@bitgopatmcl bitgopatmcl merged commit b9f0252 into BitGo:beta Aug 11, 2022
@github-actions
Copy link

🎉 This PR is included in version 1.0.0-beta.22 🎉

The release is available on npm package (@beta dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.2.0-beta.9 🎉

The release is available on npm package (@beta dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.2.0-beta.11 🎉

The release is available on npm package (@beta dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.2.0-beta.15 🎉

The release is available on npm package (@beta dist-tag)

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Sep 1, 2022

🎉 This PR is included in version 0.2.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants