summaryrefslogtreecommitdiff
path: root/backend/node/src/app.js
authorMichael Krelin <hacker@klever.net>2013-11-22 17:05:41 (UTC)
committer Michael Krelin <hacker@klever.net>2013-11-24 20:03:19 (UTC)
commitbcfe3d4f277b5d87e5c3fd56479e07f194a37144 (patch) (side-by-side diff)
treef2cdd9f27c59e4a17727d9fb353d55e04aed97da /backend/node/src/app.js
parent1180b7b195157aaeb4f0d5380e0c886bbd06c2e2 (diff)
downloadclipperz-bcfe3d4f277b5d87e5c3fd56479e07f194a37144.zip
clipperz-bcfe3d4f277b5d87e5c3fd56479e07f194a37144.tar.gz
clipperz-bcfe3d4f277b5d87e5c3fd56479e07f194a37144.tar.bz2
nodejs+postgresql backend
Diffstat (limited to 'backend/node/src/app.js') (more/less context) (ignore whitespace changes)
-rw-r--r--backend/node/src/app.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/backend/node/src/app.js b/backend/node/src/app.js
new file mode 100644
index 0000000..d4d60c2
--- a/dev/null
+++ b/backend/node/src/app.js
@@ -0,0 +1,49 @@
+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 app = EXPRESS();
+
+app.set('port', process.env.PORT || 3000);
+app.use(EXPRESS.logger('dev'));
+app.use(EXPRESS.urlencoded());
+app.use(EXPRESS.methodOverride());
+app.use(EXPRESS.cookieParser('your secret here'));
+app.use(EXPRESS.session());
+app.use(app.router);
+app.use(EXPRESS.static(PATH.join(__dirname, 'htdocs/')));
+if ('development' == app.get('env')) {
+ app.use(EXPRESS.errorHandler());
+}
+
+
+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')
+});
+
+app.post('/json',clipperz.json);
+app.get('/beta/dump',clipperz.dump);
+
+
+HTTP.createServer(app).listen(app.get('port'), function(){
+ LOGGER.info({port:app.get('port')},"Listener established");
+});