When trying to add a single property fileType, I tried multiple ways of customizing the route handlers without modifying the base code. The default approach was to create middleware. However, this proved to be problematic. The way to customize a response is to:
Create preloader middleware
Override response.send()
Read the payload and modify payload as needed. <- I was at this step...
Seems a bit complicated if I just wanted to add a filetype property. Luckily, I found that this can be easily done on the frontend and chose to do it that way. However, I can see this could be problematic in the future depending on what type of customizations that we want to do.
This change allows you to create a custom route handler by just simply copying the files in /server/routes and put them in /custom/routes and modifying it as needed. However, one caveat is the require() calls will need to be remapped to the /server versions.
Checklist
[ ] Ran npm run lint and updated code style accordingly
[ ] npm run test passes
[ ] PR has a description and all contributors/stakeholder are noted/cc'ed
[ ] tests are updated and/or added to cover new code
[ ] relevant documentation is changed and/or added
Part of #24
Description of Change
Related Issue
Motivation and Context
When trying to add a single property
fileType
, I tried multiple ways of customizing the route handlers without modifying the base code. The default approach was to create middleware. However, this proved to be problematic. The way to customize a response is to:response.send()
Seems a bit complicated if I just wanted to add a
filetype
property. Luckily, I found that this can be easily done on the frontend and chose to do it that way. However, I can see this could be problematic in the future depending on what type of customizations that we want to do.This change allows you to create a custom route handler by just simply copying the files in
/server/routes
and put them in/custom/routes
and modifying it as needed. However, one caveat is therequire()
calls will need to be remapped to the/server
versions.Checklist
npm run lint
and updated code style accordinglynpm run test
passes