This repository was archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Application structure
Ritchie Martori edited this page Apr 8, 2014
·
8 revisions
A full-stack LoopBack application follows the model-view-controller application pattern.
-
Models (LoopBack models) are defined in the application's
/modelsdirectory. -
Views are defined in the application's
/web/viewsand/html5/viewsdirectories. -
Controllers are defined in
/html5/controllers.
A full-stack LoopBack application is laid out in four sub-directories. Each directory is a separate node package.
- The
/apidirectory contains code for a "standard LoopBack" app.-
app.api.js- main app file -
configure.js- configuration settings, for example hostname and port, database logins, and so on. package.json
-
- The
/modelsdirectory contains "standard LoopBack" model definitions.-
index.js- Defines each model using the JS files in this directory, for example:exports.Todo = require('./todo'); - One JS file to define each model with
loopback.DataModel.extend(); for exampletodo.js. -
package.json- (Not sure why this is needed here?)
-
- The
/html5directory contains:-
app.html5.js- main file -
configure.js- gulp build file (?) -
package.json- (Not sure why this is needed here?) -
/controllersdirectory-
app.ctrl.js- main application controller - One
.ctrl.jsfile for each model; for example,user.ctrl.js.
-
-
/viewsdirectory - contains.htmlfiles, including one for each model; for example,user.html. -
/builddirectory - output of build process? Is this gulp output? -
/bower_componentsdirectory contains files that Bower uses to manage dependencies for front-end packages.
-
- The
/webdirectory contains: **app.js- defines routes (what else?) **run.js- Used to run the application (?) **/viewsdirectory - contains template files, such as .ejs. **package.json
NOTES: For simplicity, I did not include test directories. These can be described in an addendum.
A package consists of the following:
- a package.json
- an entry script or the "main" script of the package
- an optional library of JavaScript code
- a set of tests that cover the contents of the package
- any dependencies the package requires or references to other packages in the dependency field of package.json
- an optional configure.js script
NOTE: this section is still in flux.
- Why are there two views directories:
/web/viewsand/html5/views? What is the diff?