0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server
kirrg001 691daa2a49 ParentRouter: Added wrapper for Express Router
refs #9601

- if you call `express.Router()`, the router's name is always "router"
- that is caused by the closure behaviour in express:
  - https://github.com/expressjs/express/blob/4.16.3/lib/router/index.js#L46
- Ghost creates a couple of express routers for dynamic routing
  - it depends how much you configure in your routes.yaml file
  - but every router is called "router"
  - this is hard to work with
- with this router wrapping logic, we are able to give each router an exact name

If you enable `DEBUG=ghost:services:routing:*`, you have seen this before

> ghost:services:routing:ParentRouter site: mountRouter: router +0ms

With the wrapper logic, you will see:

> ghost:services:routing:ParentRouter site: mountRouter: StaticPagesRouter +0ms

- furthermore, if you have to access the router stack (`app.router.stack`), you can easily identify and find router instances by name
2018-06-13 21:22:10 +02:00
..
adapters 🔥 Drop Node v4 Support 2018-05-01 14:06:18 +02:00
api Added /oembed API endpoint 2018-06-12 16:18:01 +01:00
apps 🐛 Fixed preview url and Zapier on subdirectory (#9683) 2018-06-12 16:36:58 +01:00
config Replaced routeKeywords in config with hard coded keywords (#9561) 2018-04-17 10:36:05 +01:00
data Protected error if routes.yaml file doesn't contain any collections 2018-06-13 21:01:05 +02:00
helpers 🐛 Fixed preview url and Zapier on subdirectory (#9683) 2018-06-12 16:36:58 +01:00
lib Koenig - Embed card renderer 2018-06-12 16:18:01 +01:00
models Dynamic Routing Beta (#9596) 2018-06-05 19:02:20 +02:00
public 🔥 Drop Node v4 Support 2018-05-01 14:06:18 +02:00
services ParentRouter: Added wrapper for Express Router 2018-06-13 21:22:10 +02:00
translations Added /oembed API endpoint 2018-06-12 16:18:01 +01:00
views
web Added /oembed API endpoint 2018-06-12 16:18:01 +01:00
analytics-events.js
filters.js
ghost-server.js Consistent event names 2018-04-15 23:52:42 +02:00
index.js Dynamic Routing Beta (#9596) 2018-06-05 19:02:20 +02:00
overrides.js Added /oembed API endpoint 2018-06-12 16:18:01 +01:00
update-check.js 🔥 Drop Node v4 Support 2018-05-01 14:06:18 +02:00