forked from nodezoo/nodezoo-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
64 lines (48 loc) · 1.24 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"use strict";
var express = require('express')
var seneca = require('seneca')()
var logentries = require('node-logentries'), log
try {
seneca.use( 'config', {object:require('./config.mine.js')} )
}
catch(e) {
console.log(e)
}
seneca.act(
{role:'config',cmd:'get',base:'nodezoo',default$:{
web: { port: 8101 }
}},
function(err,config){
if( err ) throw err;
if( config.logentries ) {
log = logentries.logger({token:config.logentries.token})
}
else {
log = {
debug: console.log,
info: console.log,
notice: console.log,
warning: console.log,
err: console.log,
crit: console.log,
alert: console.log,
emerg: console.log,
log: console.log,
}
}
seneca.use( './lib/nodezoo', {log:log} )
start_express(config)
})
function start_express(config) {
var app = express()
app.use(express.cookieParser())
app.use(express.query())
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.json())
app.use(express.static(__dirname+'/site/public'))
//app.use(express.session({ secret: 'waterford' }))
app.use( seneca.service() )
log.info('start '+config.instance)
app.listen( config.web.port )
}