Ghost/core/server
Katharina Irrgang 6a4af1f465
Rewrite url service (#9550)
refs https://github.com/TryGhost/Team/issues/65

We are currently work on dynamic routing (aka channels).
An important piece of this feature is the url service, which always knows the url of a resource at any time.
Resources can belong to collections or taxonomies, which can be defined in a [routing yaml file](https://github.com/TryGhost/Ghost/issues/9528). We are currently shipping portions, which will at end form the full dynamic routing feature.

### Key Notes

- each routing type (collections, taxonomies, static pages) is registered in order - depending on the yaml routes file configuration
- static pages are an internal concept - they sit at the end of the subscriber queue
- we make use of a temporary [`Channels2`](https://github.com/TryGhost/Ghost/pull/9550/files#diff-9e7251409844521470c9829013cd1563) file, which simulates the current static routing in Ghost (this file will be modified, removed or whatever - this is one of the next steps)
- two way binding: you can ask for a resource url based on the resource id, you can ask for the resource based on the url
- in theory it's possible that multiple resources generate the same url: we don't handle this with collision (because this is error prone), we handle this with the order of serving content. if you ask the service for a resource, which lives behind e.g. /test/, you will get the resource which is served
- loose error handling -> log errors and handle instead of throw error and do nothing (we log the errors with a specific code, so we can react in case there is a bug)
- the url services fetches all resources on bootstrap. we only fetch and keep a reduced set of attributes (basically the main body of a resource)
- the bootstrap time will decrease a very little (depending on the amount of resources you have in your database)
- we still offer the option to disable url preloading (in your config `disableUrlPreload: true`) - this option will be removed as soon as the url service is connected. You can disable the service in case you encounter a problem
- **the url service is not yet connected, we will connect the service step by step. The first version should be released to pre-catch bugs. The next version will add 503 handling if the url service is not ready and it will consume urls for resources.**


----

- the url service generates urls based on resources (posts, pages, users, tags)
- the url service keeps track of resource changes
- the url service keeps track of resource removal/insert
- the architecture:
  - each routing type is represented by a url generator
    - a routing type is a collection, a taxonomiy or static pages
  - a queue which ensures that urls are unique and can be owned by one url generator
    - the hierarchy of registration defines that
  - we query knex, because bookshelf is too slow
- removed old url service files + logic
- added temp channels alternative (Channels2) -> this file will look different soon, it's for now the temporary connector to the url service. Also the name of the file is not optimal, but that is not really important right now.
2018-04-17 11:29:04 +02:00
..
adapters Moved utils constants to lib/constants 2017-12-14 14:13:40 +01:00
api Simplify destroy post API endpoint implementation 2018-04-06 15:49:25 +02:00
apps Redirected /amp links to original post when AMP is disabled (#9496) 2018-03-19 16:11:48 +07:00
config YAML settings loader and parser 2018-04-15 19:40:22 +02:00
controllers 🐛 Fixed post preview 2018-04-15 10:08:06 +02:00
data 🐛 Fixed importer bug: can't resolve authors relation 2018-04-10 01:10:06 +02:00
helpers Multiple authors (#9426) 2018-03-27 15:16:15 +01:00
lib Fix Node.js 4.x compatibility (#9503) 2018-03-15 09:50:25 +00:00
models Rewrite url service (#9550) 2018-04-17 11:29:04 +02:00
public 🛠 🙈 Rename ghost-url.js to ghost-sdk.js (#8767) 2017-07-28 18:23:32 +04:00
services Rewrite url service (#9550) 2018-04-17 11:29:04 +02:00
translations YAML settings loader and parser 2018-04-15 19:40:22 +02:00
views Fixed error trying to render 404 for missing asset 2017-12-22 20:08:59 +00:00
web Rewrite url service (#9550) 2018-04-17 11:29:04 +02:00
analytics-events.js Cleared out old unused events 2017-12-13 09:08:25 +00:00
filters.js Moved pipeline/sequence to lib/promise 2017-12-13 22:20:02 +01:00
ghost-server.js Consistent event names 2018-04-15 23:52:42 +02:00
index.js Trigger database ready event 2018-04-15 23:53:18 +02:00
overrides.js Set Promise to be Bluebird globally 2017-12-13 20:57:11 +01:00
update-check.js Update Notification improvements (#9123) 2018-01-09 15:20:00 +01:00