1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/CONTRIBUTING.md
Ivar Conradi Østhus 2bcdb5ec31
fix: Controller wraps handler with try/catch (#909)
By having the controller perform try/catch around the
handler function allows us to add extra safety to all
our controllers and safeguards that we will always catch
exceptions thrown by a controller method.
2021-08-13 10:36:19 +02:00

3.4 KiB

Contributing to Unleash

Getting started

Before you begin:

Don't see your issue? Open one

If you spot something new, open an issue. We'll use the issue to have a conversation about the problem you want to fix.

Ready to make a change? Fork the repo

Fork using GitHub Desktop:

Fork using the command line:

  • Fork the repo so that you can make your changes without affecting the original project until you're ready to merge them.

Fork with GitHub Codespaces:

Make your update:

Make your changes to the file(s) you'd like to update. You'll need Node.js v14 and PostgreSQL 10 to run Unleash locally. See more details

Open a pull request

When you're done making changes and you'd like to propose them for review by opening a pull request.

Submit your PR & get it reviewed

  • Once you submit your PR, others from the Unleash community will review it with you. The first thing you're going to want to do is a self review.
  • After that, we may have questions, check back on your PR to keep up with the conversation.
  • Did you have an issue, like a merge conflict? Check out GitHub's git tutorial on how to resolve merge conflicts and other issues.

Your PR is merged!

Congratulations! The whole Unleash community thanks you.

Once your PR is merged, you will be proudly listed as a contributor in the contributor chart.

Nice to know

Controllers

In order to handle HTTP requests we have an abstraction called Controller. If you want to introduce a new route handler for a specific path (and sub pats) you should implement a controller class which extends the base Controller. An example to follow is the routes/admin-api/feature.ts implementation.

The controller takes care of the following:

  • try/catch RequestHandler method
  • error handling with proper response code if they fail
  • await the RequestHandler method if it returns a promise (so you don't have to)
  • access control so that you can just list the required permission for a RequestHandler and the base Controller will make sure the user have these permissions.