Start with node --harmony app.js
Models are made with the help of Mongoose Schemas.
Create a file with the name of the model in the models/ folder As an example you have the models/user.js. This will create a model named "User" (user.js => User)
Create a file in the controllers folder.
// User Controllermodule.exports={name: 'User',// the name of the controllerdata: {// object of needed data, optionalsomeData: true},methods: {all: function(req,res){res.json({users: []})}},needs: ['SomeController']}The name of the controller
Object containing data
data: {property: true}This will be available as Controller.property , so don't use the same name for data and methods
Self explanatory
The framework loads all controllers with data and methods and then puts the dependencies in every one of them. In this case, other dependencies are controllers that may be needed.
needs: ['Auth']This will load the Auth controller in Controller.authController
You just have to edit the routes/http.js file. Out Route method is just a wrapper for Express app.method for now, we'll extend to express Router later.
Route.get('/users','User@getAll');You can user Route.get exactly as you would use Express app.get. The only difference is that you can also use 'Controller@method' instead of a function.
You should rename the example.config.js to config.js. This file contains a example config file with all the info that Parts need to run. You can add other keys to this config and they will be available.
varconfig=use('Config');console.log(config.http.port);// gives exactly thatconsole.log(config.http.asd);// gives undefinedconsole.log(config.getValue('http.asd'));// gives nullconsole.log(config.getValue('http.asd','aa'));// gives 'aa'varConfig=use('Config');// This will return the ConfigvarRoute=use('Route');// This will return Route object (the methods are the http methods from app in express)varUser=use('User');// This will return the User controller. No, this is not predefined. Every capitalized string (except Config and Route) will be identified as a controller name.vargetAll=use('User@getAll');// This will return getAll method / property of the User ControllervarUser=use('#User');// This will return the Mongoose Model named 'User';