wp-pwa / services

A series of serverless microservices that power up the WP REST API
https://services.frontity.cloud
Apache License 2.0
0 stars 0 forks source link

[0] Services should be chainable #9

Open SantosGuillamot opened 5 years ago

SantosGuillamot commented 5 years ago

Multiple services can be used together, so chaining them must work. Things like: https://services.frontity.cloud/add-media-ids/https://services.frontity.cloud/add-title/https://blog.frontity.com/?rest_route=/wp/v2/posts&per_page=10&_embed=true

We should also take a look at "why" they are not working right now (cdn.frontity.cloud works) to figure out the correct pattern and use it in the future with other services.

orballo commented 5 years ago

They can't be chained because the way the initial evaluation of the url works doesn't handle the case where there is more than one base url.

https://github.com/frontity/services/blob/ec9ab03eee01f03a03d7219d55eee7ec5ae99920/services/add-media-ids/src/index.js#L12

The values retrieved in this line will be wrong.

One solution might be to use a regexp to get the last url in the chain, and use it to make the complementary calls, for example to populate media. But the main call should use the full url.