mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
b545dfa0cc
fixes https://github.com/TryGhost/Product/issues/3900 1. The service never returns a Recommendation Entity, but always plain objects (which for now is the same as Recommendation without the methods). 2. Updated the controller to be more readable and minimal (we keep this controller, in addition to the existing endpoints and serializers) - The controller does minimal validation and allows for type checking (so we get compile time errors in case the service expects new fields) - The controller uses the `UnsafeData` class to easily validate the input from requests, and throws appropriate errors (with correct field descriptions — "Expected a string at recommendations.0.title") without too much boilerplate code. In addition the interface is typed, so we get compile errors if there are breaking changes in the service. - Removed `EntityWithIncludes`, since we now use plain objects, we inject the relations directly into those plain objects (with some new types that add type support) - Added new tests to make sure that edits only affect the given fields, and never undefined fields |
||
---|---|---|
.. | ||
src | ||
test | ||
.eslintrc.js | ||
package.json | ||
README.md | ||
tsconfig.json |
Recommendations
Usage
Develop
This is a monorepo package.
Follow the instructions for the top-level repo.
git clone
this repo &cd
into it as usual- Run
yarn
to install top-level dependencies.
Test
yarn lint
run just eslintyarn test
run lint and tests