koainit

3.2.4 • Public • Published

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

Package Sidebar

Install

npm i koainit

Weekly Downloads

0

Version

3.2.4

License

MIT

Last publish

Collaborators

  • mztmm