You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Konstantin Käfer edited this page May 17, 2011
·
2 revisions
Modules providing functionality to a Bones application are called plugins. Every plugin has the same structure: An index.js file, and models, views, controllers, commands and/or servers in subdirectories. Bones’ core functionality is also implemented as a plugin; the only difference is that Bones loads it automatically.
index.js
// Load child pluginsrequire('tilestream');require('bones-auth');// Load this pluginrequire('bones').load(__dirname);if(module.parent){// Start processing commandsrequire('bones').start();}
Load order
Within a plugin, the default load order is:
Controllers
Models
Templates
Views
Servers
Commands
Among each kind, files are loaded alphabetically. If this doesn't work for you (e.g. when your Countries collection depends on the Country model), add requires to these files to index.js:
// Required to initialize loader for *.bones filesrequire('bones');// Explicit load orderrequire('./models/country');require('./models/countries');// Load the rest of this pluginrequire('bones').load(__dirname);
When loading multiple plugins, all files of one plugin are loaded before Bones proceeds to load the next plugin.
Components are sent to the client in the same order they were loaded on the server, i.e. you can influence the client's load order by using require() in index.js.