Created
May 2, 2012 21:34
-
-
Save olivernn/2580681 to your computer and use it in GitHub Desktop.
multiple 'apps' within one davis app
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
var cartApp = function () { | |
this.scope('/cart', function () { | |
this.post('/items', function (req) { | |
// create an item | |
}) | |
this.del('/items/:id', function (req) { | |
// delete a specific item from your cart | |
}) | |
this.get('/items/:id', function (req) { | |
// get details about a specific item in the car | |
}) | |
}) | |
} |
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
var chatApp = function () { | |
this.scope('/chat', function () { | |
this.post('/message', function (req) { | |
// create a message in your chat app | |
}) | |
}) | |
} |
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
var app = Davis(function () { | |
this.use(chatApp) | |
this.use(cartApp) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can implement something approaching multiple apps using plugins. A plugin is basically just a function that gets called with the context of the current app.
This way you get some separation of the different apps and their routes etc, but they are both included in the same 'main' davis app.