-
Notifications
You must be signed in to change notification settings - Fork 90
Lf 4765 [draft] - for consideration #3772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration
Are you sure you want to change the base?
Lf 4765 [draft] - for consideration #3772
Conversation
5f7cf24
to
39cb768
Compare
|
||
// Check auth | ||
// NOTE: Consider making this a separate middleware with checkJwt | ||
if (!req.auth) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not exist here prior to this PR.
IrrigationPrescriptionRequestController.initiateFarmIrrigationPrescription(), | ||
); | ||
router.post('/', checkScope(['get:smart_irrigation']), (req, res) => { | ||
const typedReq = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change 1...
const typedReq = req as ScopeCheckedLiteFarmRequest<Partial<IrrigationPrescriptionQueryParams>>; | ||
checkGetIrrigationPrescription()(typedReq, res, next); | ||
}, | ||
(req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change 2...
@kathyavini Did you end up seeing any value with merging these typescript formalities? Or can I close the PR? |
@Duncan-Brain do you want to close it because you don't think it's the best approach anymore? I wasn't sure where that conversation in the other thread landed -- particularly if you were in agreement with Anto that the benefit was too marginal for the diff (then yes, please do close) or if you still think this is the more thorough/correct solution. If the second, since the |
@kathyavini I do think it is the more thorough... but any help evaluating that is appreciated (obv no rush as you said) I think the actual lines of code for the fix are lowish.. the The main benefits as I see them are
Drawbacks
My understanding is express typings are not great so tradeoffs are probably necessary. |
Description
Addresses a comment in LF-4765
The main challenge with express is there seems to be no way to communicate between middlewares that the type on the request object have been narrowed. I feels like NextFunction type should do something like that but I dno.
This option casts the type in the route so that it is clear that it should be alongside checkScope() middleware.
Notes:
Jira link:
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
pnpm i18n
to help with this)