1. Installation
npm install -g geddy2. Building an App
geddy gen app task3. Starting geddy Server
C:\Node4Geddy>cd task
C:\Node4Geddy\task>geddy
[Mon, 13 Feb 2017 12:38:57 GMT] INFO Server starting with config: {
"environment": "development",
"workers": 1,
"port": 4000,
"spdy": null,
"ssl": null,
"detailedErrors": true,
"requestTimeout": null,
"flash": {
"defaultClass": "alert",
"inlineClasses": {
"success": "alert alert-success",
"alert": "alert",
"error": "alert alert-error",
"info": "alert alert-info"
},
"blockClasses": {
"success": "alert alert-block alert-success",
"alert": "alert alert-block",
"error": "alert alert-block alert-error",
"info": "alert alert-block alert-info"
}
},
"debug": true,
"watch": {
"files": [
"/config",
"/lib",
"/app/controllers",
"/app/models",
"/app/views",
"/app/helpers"
],
"includePattern": "\\.(js|coffee|css|less|scss)$",
"excludePattern": "\\.git|node_modules"
},
"rotateWorkers": false,
"rotationWindow": 7200000,
"rotationTimeout": 300000,
"logDir": "C:\\Node4Geddy\\task\\log",
"gracefulShutdownTimeout": 30000,
"heartbeatInterval": 5000,
"heartbeatWindow": 20000,
"staticFilePath": "C:\\Node4Geddy\\task\\public",
"assetHost": "",
"assetBasePath": "/",
"cacheControl": {
"expires": {
"default": 0
}
},
"sessions": {
"store": "filesystem",
"key": "sid",
"expiry": 1209600,
"filename": "_session_store.json"
},
"cookieSessionKey": "sdata",
"i18n": {
"defaultLocale": "en-us",
"loadPaths": [
"C:\\Node4Geddy\\task\\config\\locales"
]
},
"appName": "Geddy App (development)",
"hostname": null,
"fullHostname": null,
"connectCompatibility": false,
"mailer": null,
"generatedByVersion": "13.0.8",
"model": {
"defaultAdapter": "filesystem"
}
}
[Mon, 13 Feb 2017 12:38:57 GMT] INFO Creating 1 worker process.
[Mon, 13 Feb 2017 12:38:57 GMT] INFO Server worker running in development on por
t 4000 with a PID of: 3704
4. Scaffolding Resources
geddy gen scaffold task title:default status
C:\Node4Geddy\task>geddy gen scaffold step title:default description:text status
[Added] app\models\step.js
[Added] db\migrations\20170213204944_create_steps.js
[Added] test\models\step.js
[Added] test\controllers\steps.js
[Added] app\controllers\steps.js
[Added] Resource steps route added to config\router.js
[Added] View templates
C:\Node4Geddy\task>
5. Add Validations
var ToDo = function () { ... // Add this inside the constructor function this.validatesPresent('title'); this.validatesLength('title', {min: 5}); this.validatesWithFunction('status', function (status) { return status == 'open' || status == 'done'; }, {message: "Status must be 'open' or 'done.'"}); ... }; ToDo = geddy.model.register('ToDo', ToDo);
6. Create Associations
var ToDo = function () {
...
this.hasMany('Steps');
...
};
var Step = function () {
...
this.belongsTo('ToDo');
...
};
Step = geddy.model.register('Step', Step);
No comments:
Post a Comment