summaryrefslogtreecommitdiff
path: root/backend/node
Unidiff
Diffstat (limited to 'backend/node') (more/less context) (ignore whitespace changes)
-rw-r--r--backend/node/src/app.js18
-rw-r--r--backend/node/src/clipperz.js2
-rw-r--r--backend/node/src/package.json15
3 files changed, 20 insertions, 15 deletions
diff --git a/backend/node/src/app.js b/backend/node/src/app.js
index 61c2c72..ca05e6f 100644
--- a/backend/node/src/app.js
+++ b/backend/node/src/app.js
@@ -25,27 +25,27 @@ var clipperz = CLIPPERZ({
25 logger: LOGGER, 25 logger: LOGGER,
26 dump_template: PATH.join(__dirname,'htdocs/beta/index.html') 26 dump_template: PATH.join(__dirname,'htdocs/beta/index.html')
27}); 27});
28 28
29 29
30var app = EXPRESS(); 30var app = EXPRESS();
31 31
32app.set('port', process.env.PORT || 3000); 32app.set('port', process.env.PORT || 3000);
33app.use(EXPRESS.logger('dev')); 33app.use(require('morgan')('dev'));
34app.use(EXPRESS.urlencoded()); 34app.use(require('body-parser').urlencoded({extended:true}));
35app.use(EXPRESS.methodOverride()); 35app.use(require('cookie-parser')('your secret here'));
36app.use(EXPRESS.cookieParser('your secret here')); 36app.use(require('express-session')({secret:'99 little bugs in the code', key:'sid', store: clipperz.session_store(), resave: false, saveUninitialized: false }));
37app.use(EXPRESS.session({secret:'99 little bugs in the code', key:'sid', store: clipperz.session_store() })); 37
38app.use(app.router); 38app.post('/json',clipperz.json);
39app.get('/beta/dump',clipperz.dump);
40
39app.use(EXPRESS.static(PATH.join(__dirname, 'htdocs/'))); 41app.use(EXPRESS.static(PATH.join(__dirname, 'htdocs/')));
40if ('development' == app.get('env')) { 42if ('development' == app.get('env')) {
41 app.use(EXPRESS.errorHandler()); 43 app.use(require('express-error-with-sources')());
42} 44}
43 45
44 46
45app.post('/json',clipperz.json);
46app.get('/beta/dump',clipperz.dump);
47 47
48 48
49HTTP.createServer(app).listen(app.get('port'), function(){ 49HTTP.createServer(app).listen(app.get('port'), function(){
50 LOGGER.info({port:app.get('port')},"Listener established"); 50 LOGGER.info({port:app.get('port')},"Listener established");
51}); 51});
diff --git a/backend/node/src/clipperz.js b/backend/node/src/clipperz.js
index 04b054a..c51b0bc 100644
--- a/backend/node/src/clipperz.js
+++ b/backend/node/src/clipperz.js
@@ -1,14 +1,14 @@
1var FS = require('fs'); 1var FS = require('fs');
2var CRYPTO = require('crypto'); 2var CRYPTO = require('crypto');
3var BIGNUM = require('bignum'); 3var BIGNUM = require('bignum');
4var ASYNC = require('async'); 4var ASYNC = require('async');
5 5
6var express_store = require('express').session.Store; 6var express_store = require('express-session').Store;
7 7
8function clipperz_hash(v) { 8function clipperz_hash(v) {
9 return CRYPTO.createHash('sha256').update( 9 return CRYPTO.createHash('sha256').update(
10 CRYPTO.createHash('sha256').update(v).digest('binary') 10 CRYPTO.createHash('sha256').update(v).digest('binary')
11 ).digest('hex'); 11 ).digest('hex');
12}; 12};
13function clipperz_random() { 13function clipperz_random() {
14 for(var r = '';r.length<64;r+=''+BIGNUM(Math.floor(Math.random()*1e18)).toString(16)); 14 for(var r = '';r.length<64;r+=''+BIGNUM(Math.floor(Math.random()*1e18)).toString(16));
diff --git a/backend/node/src/package.json b/backend/node/src/package.json
index 825f756..98755bd 100644
--- a/backend/node/src/package.json
+++ b/backend/node/src/package.json
@@ -1,15 +1,20 @@
1{ 1{
2 "name": "clipperz", 2 "name": "clipperz",
3 "version": "0.0.0", 3 "version": "0.0.0",
4 "private": true, 4 "private": true,
5 "scripts": { 5 "scripts": {
6 "start": "node app 2>&1 | ./node_modules/.bin/bunyan" 6 "start": "node app 2>&1 | ./node_modules/.bin/bunyan"
7 }, 7 },
8 "dependencies": { 8 "dependencies": {
9 "express": "3.4.4", 9 "async": "^0.9.0",
10 "async": "~0.2.9", 10 "bignum": "^0.8.0",
11 "bignum": "~0.6.2", 11 "body-parser": "^1.4.3",
12 "pg": "~2.8.3", 12 "bunyan": "^0.23.1",
13 "bunyan": "~0.22.0" 13 "cookie-parser": "^1.3.2",
14 "express": "^4.4.5",
15 "express-error-with-sources": "^1.3.1",
16 "express-session": "^1.6.1",
17 "morgan": "^1.1.1",
18 "pg": "^3.3.0"
14 } 19 }
15} 20}