-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor/homepage #331
Refactor/homepage #331
Conversation
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.
lgtm with some minor clarifications
newroutes/homepage.js
Outdated
const { error } = UpdateHomepageSchema.validate(req.body, { | ||
allowUnknown: true, | ||
}) |
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.
i think this is a good pattern that we should be using going forward! we validate unknown data and ensure that it's of a valid shape before passing it onto our services!
bbd8028
to
afb1d07
Compare
2610f33
to
830ca4c
Compare
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.
minor comments but looking good overall!
newroutes/homepage.js
Outdated
|
||
router.get( | ||
"/:siteName/homepage", | ||
attachReadRouteHandlerWrapper(this.readHomepage) |
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.
i think once we shift to ts, we can try doing this with decorators to see if it eases the friction!
1b04b91
to
c34bedf
Compare
e69ff47
to
91fd3cf
Compare
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.
lgtm once extra test case is added and behaviour of FE clarified
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.
lgtm
42e416c
to
c49a6be
Compare
* Feat: add updateHomepageSchema * Feat: add homepage router * Fix: allow pageBody for updateHomepage * Test: add tests for homepage router * Nit: line spacing * Chore: add comment for empty string in schema * Nit: fix comment for error type importing * Fix: throw only error.message from joi * Rebase: inject auth middleware verify into router * Nit: rename variable * Fix: allow empty description and notification * Fix: use subrouter for homepage * Fix: test location * Fix: retrieve accessToken from res.locals * Fix: use fixtures and omit in homepage tests * Feat: add read failure to homepage test suite
Overview
This PR adds the refactored homepage router, in line with our recent refactoring efforts. It builds off the existing HomepagePageService that already exists for use by the SettingsRouter. It also adds the relevant tests for the homepage router component.
The media categories router contains the following endpoints:
GET /:siteName/homepage - Retrieve homepage information
POST /:siteName/homepage- Update homepage information
Notes
I have opted for a looser schema of the updateHomepage request (e.g. not checking all section details), as several sites have additional details in the front matter of their homepage due to legacy issues, though I am open to suggestions on what we could do if we want to enforce a stricter format.