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
|
var BUNYAN = require('bunyan');
var LOGGER = BUNYAN.createLogger({
name: 'clipperz',
streams: [
{ name: "console", stream:process.stderr,level:'trace'}
],
serializers: {
req: BUNYAN.stdSerializers.req,
res: BUNYAN.stdSerializers.res,
err: BUNYAN.stdSerializers.err
},
src: true
});
var EXPRESS = require('express');
var HTTP = require('http');
var PATH = require('path');
var CLIPPERZ = require('./clipperz');
var CONF = require('./conf');
var clipperz = CLIPPERZ({
psql: CONF.psql||'postgresql:///clipperz',
logger: LOGGER,
dump_template: PATH.join(__dirname,'htdocs/beta/index.html')
});
var app = EXPRESS();
app.set('port', process.env.PORT || 3000);
app.use(require('morgan')('dev'));
app.use(require('body-parser').urlencoded({extended:true}));
app.use(require('cookie-parser')('your secret here'));
app.use(require('express-session')({secret:'99 little bugs in the code', key:'sid', store: clipperz.session_store(), resave: false, saveUninitialized: false }));
app.post('/json',clipperz.json);
app.get('/beta/dump',clipperz.dump);
app.use(EXPRESS.static(PATH.join(__dirname, 'htdocs/')));
if ('development' == app.get('env')) {
app.use(require('express-error-with-sources')());
}
HTTP.createServer(app).listen(app.get('port'), function(){
LOGGER.info({port:app.get('port')},"Listener established");
});
|