koainit
v3.2.4
Published
init koa
Downloads
12
Readme
koaInit
Install
npm install koainit
How to use
var path = require("path");
var app = require("koaInit")({
"staticPath":"public"/path["join"](__dirname,"public"),
"htmlPath":"views"/path["join"](_dirname,"views")
});
model
"staticPath":(css/js)path Directory. value is: DirectoryName/DirectoryPath;
"staticPath":(html/jade)path Directory. value is: DirectoryName/DirectoryPath;
ejs
"layout":true/false nullable defaule:false
"viewExt":html/jade nullable defaule:html
"cache":true/false nullable defaule:false
"debug":true/false nullable defaule:true
"locals":{} nullable
defaule:{
version : '0.0.1',
now : function () {
return new Date ();
},
ip : function * () {
return this [ "ip" ];
}
}
https
"httpsKey":path["join"](_dirname,"httpsKey")
"httpsCert":path["join"](_dirname,"httpsCert")
listen
var path = require("path");
var app = require("koaInit")({
"staticPath":"public"/path["join"](__dirname,"public"),
"htmlPath":"views"/path["join"](_dirname,"views"),
"listen":80
});
or
var socketio = require("socket.io");
var path = require("path");
var app = require("koaInit")({
"staticPath":"public"/path["join"](__dirname,"public"),
"htmlPath":"views"/path["join"](_dirname,"views"),
"httpsKey":path["join"](_dirname,"httpsKey"),
"httpsCert":path["join"](_dirname,"httpsCert"),
"listen":
[80,
"81",
{"listen":82},
{"listen":83,"socketIO":socketio,"socketCall":function(socket,io){socket["on"](key,function(data){socket["emit"]("key",{});});}},
{"listen":84,"socketIO":socketio,"socketCall":function(socket,io){socket["on"](key,function(data){socket["emit"]("key",{});};)},"https":true},
{"listen":85,"https":true}]
});
router
var socketio = require("socket.io");
var path = require("path");
var app = require("koaInit")({
"staticPath":"public"/path["join"](__dirname,"public"),
"htmlPath":"views"/path["join"](_dirname,"views"),
"httpsKey":path["join"](_dirname,"httpsKey"),
"httpsCert":path["join"](_dirname,"httpsCert"),
"listen":
[80,
"81",
{"listen":82},
{"listen":83,"socketIO":socketio,"socketCall":function(socket,io){socket["on"](key,function(data){socket["emit"]("key",{});});}},
{"listen":84,"socketIO":socketio,"socketCall":function(socket,io){socket["on"](key,function(data){socket["emit"]("key",{});};)},"https":true},
{"listen":85,"https":true}]
});
app["router"]["get"]("/",function * (next){
this.body="Hello Work!";
})
href
- http://127.0.0.1
- http://127.0.0.1:81
- http://127.0.0.1:82
- http://127.0.0.1:83
- https://127.0.0.1:84
- https://127.0.0.1:85