Skip to content

Instantly share code, notes, and snippets.

@olivernn
Created May 2, 2012 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivernn/2580681 to your computer and use it in GitHub Desktop.
Save olivernn/2580681 to your computer and use it in GitHub Desktop.
multiple 'apps' within one davis app
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
})
})
}
var chatApp = function () {
this.scope('/chat', function () {
this.post('/message', function (req) {
// create a message in your chat app
})
})
}
var app = Davis(function () {
this.use(chatApp)
this.use(cartApp)
})
@olivernn
Copy link
Author

olivernn commented May 2, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment