Ghost/ghost/recommendations
Simon Backx b545dfa0cc
Improved recommendation controller structure (#18208)
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
2023-09-18 14:36:49 +00:00
..
src Improved recommendation controller structure (#18208) 2023-09-18 14:36:49 +00:00
test Added recommendations CRUD api (#17845) 2023-08-29 15:06:57 +00:00
.eslintrc.js Added recommendations CRUD api (#17845) 2023-08-29 15:06:57 +00:00
package.json Added BookshelfRepository and BookshelfRecommendationRepository 2023-09-01 15:10:34 +02:00
README.md Added recommendations CRUD api (#17845) 2023-08-29 15:06:57 +00:00
tsconfig.json Added recommendations CRUD api (#17845) 2023-08-29 15:06:57 +00:00

Recommendations

Usage

Develop

This is a monorepo package.

Follow the instructions for the top-level repo.

  1. git clone this repo & cd into it as usual
  2. Run yarn to install top-level dependencies.

Test

  • yarn lint run just eslint
  • yarn test run lint and tests