Skip to content
This repository
Browse code

Updated readme, shrunk size of beach bg

  • Loading branch information...
commit 2af14c5d3406dc2bfc720b45a3510ad94ba79e7c 1 parent 21efcb1
Hunter Loftis authored
41 README.md
Source Rendered
@@ -56,11 +56,13 @@ run.js -- runs your app
56 56 cycle.js -- watches local files and builds/runs on changes (for development)
57 57 ```
58 58
59   -When base12 starts, it runs `/index.js`, which uses `base12.balance()` to balance app processes via `cluster` (1 process per cpu).
  59 +## Startup process...
60 60
61   -Each process runs `/app/index.js`, which creates a new app with `base12.app()`. The `app` instance is passed into all modules.
62   -
63   -Once all modules have run, the app starts listening for requests.
  61 + 1. `node cycle` builds your app and calls `run.js`.
  62 + 2. `run.js` uses base12.balance() to run `app/index.js`.
  63 + 3. `app/index.js` loads everything from `app/(models, views, controllers, middleware)`.
  64 + 4. `app/index.js` opens `app/lib/index.json` and runs lib files in the order specified by `autorun`.
  65 + 5. `app/index.js` starts listening for requests.
64 66
65 67 ## Writing controllers, models, middleware, and libs
66 68
@@ -73,6 +75,37 @@ module.exports = function(app) {
73 75 }
74 76 ```
75 77
  78 +For example, a controller might look like:
  79 +
  80 +```javascript
  81 +module.exports = function(app) {
  82 + return {
  83 + index: function(req, res) {
  84 + var widgets = app.models.widgets.get_all();
  85 + res.send(widgets);
  86 + },
  87 + show: function(req, res) {
  88 + var widget = app.models.widget.get_one();
  89 + res.send(widget);
  90 + }
  91 + };
  92 +};
  93 +```
  94 +
  95 +A model (using mongoose) might look like:
  96 +
  97 +```javascript
  98 +var mongoose = require('mongoose');
  99 +
  100 +module.exports = function(app) {
  101 + var WidgetSchema = new mongoose.Schema({
  102 + name: String
  103 + });
  104 +
  105 + return mongoose.Model('widget', WidgetSchema);
  106 +};
  107 +```
  108 +
76 109 ## Updating constants and config
77 110
78 111 Application constants (values that do not change from machine to machine) are located under `constants` in package.json.
BIN  app/public/images/clifton_beach.jpg

0 comments on commit 2af14c5

Please sign in to comment.
Something went wrong with that request. Please try again.