-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored apps to have access to a router
refs #9192 - Instead of `setupRoutes` function in apps that gets passed a router, there is now a registerRouter function as part of the proxy - Moved towards a route service, which will know about all routes - Using classes to abstract away shared behaviour Notes: - changing the app proxy didn't result in a test failure! - structure of route service is totally new and may change a lot yet
- Loading branch information
Showing
8 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* An instance of router that is provided to Apps, to mount routes into. | ||
*/ | ||
|
||
var debug = require('ghost-ignition').debug('services:routes:app'), | ||
Router = require('./base/Router'); | ||
|
||
class AppRouter extends Router { | ||
registerRouter(path, router) { | ||
debug('registerRouter for', path); | ||
this.router.use(path, router); | ||
} | ||
} | ||
|
||
module.exports = AppRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var expressRouter = require('express').Router; | ||
|
||
class Router { | ||
constructor() { | ||
this.router = expressRouter({mergeParams: true}); | ||
} | ||
} | ||
|
||
module.exports = Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* # Route Service | ||
* | ||
* Everything in here is 100% experimental | ||
*/ | ||
|
||
var AppRouter = require('./AppRouter'); | ||
|
||
module.exports.appRouter = new AppRouter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters