# Abstract
do-faramework is SIMPLE Node.js framework.
Features
- Very simple in structure, easy to custom.
- There are very few CALLBACK, source code is easy to see.
- Easy to see the working directory of programmers and designers.
Installation
Before installing, download and install Node.js and npm.
npm -g install do-framework
Create Project
Project directory can be created with the following command.
do-framework [project name]
Example(http server)
①. create file "/back/http/controller.js" and input the following code.
【controller.js】
var Do = module.parent.exports.Do; exports['action'] = function* (req, res) { return Do.output.view('controller/action', { title: 'TEST TITLE' });}
②. create file "/front/view/controller/action.ejs" and input the following code.
【action.ejs】
<%= title %>test
③. start http server in root of project directory
npm run start
④. access http or https ://host:port/controller/action
you can see sample page!
Example(socket.io)
①. create file "/back/http/controllerio.js" and input the following code.
【controllerio.js】
var Do = module.parent.exports.Do; exports['actionio'] = function* (req, res) { return Do.output.view('controller/viewIo', { title: 'TEST TITLE2' });}
②. create file "/front/view/controller/action.ejs" and input the following code.
【viewio.ejs】
<%= title %>
③. create file "/back/io/test.js" and input the following code.
var Do = module.parent.exports.Do;exports['send'] = function* (socket, data) { socket.emit('send', 'sended!');}
④. start http server in root of project directory
npm run start
⑤. access http or https ://host:port/controllerio/actionio
you can see "sended!" alert!
Example(batch)
①. create file "/back/batch/test.js" and input the following code.
【test.js】
var Do = module.parent.exports.Do; exports['go'] = function* (args) { console.log("batch done!") return "OK";}
②. start batch in root of project directory
npm run batch test/go
you can see "batch done!" text in console
Boot option
see package.json
: "scripts": { "start": "NODE_ENV=ENV1 NODE_BATCH=0 node app.js", "batch": "NODE_ENV=ENV1 NODE_BATCH=1 node app.js" },:
NODE_ENV
When boot node, load config file in config/【NODE_ENV】 directory
e.g.
LOADED config/ENV1/Do.js
LOADED config/ENV1/http.js
LOADED config/ENV1/mongo.js
LOADED config/ENV1/mysql.js
LOADED config/ENV1/redis.js
NODE_BATCH
execute batch program or not.