author | Michael Krelin <hacker@klever.net> | 2014-07-01 17:49:10 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2014-07-01 17:49:10 (UTC) |
commit | a6e5df547739ac91055ae0ae4928447c9ec50a98 (patch) (unidiff) | |
tree | e5d2e63d8c782bb471fa95bd8c7d6d21e3c322b0 /backend | |
parent | b9ee39b810aae10da83534776028585309b53a24 (diff) | |
download | clipperz-a6e5df547739ac91055ae0ae4928447c9ec50a98.zip clipperz-a6e5df547739ac91055ae0ae4928447c9ec50a98.tar.gz clipperz-a6e5df547739ac91055ae0ae4928447c9ec50a98.tar.bz2 |
-rw-r--r-- | backend/node/src/app.js | 7 | ||||
-rw-r--r-- | backend/node/src/clipperz.js | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/backend/node/src/app.js b/backend/node/src/app.js index bbc62f8..09dcfac 100644 --- a/backend/node/src/app.js +++ b/backend/node/src/app.js | |||
@@ -32,16 +32,17 @@ var app = EXPRESS(); | |||
32 | app.set('port', process.env.PORT || 3000); | 32 | app.set('port', process.env.PORT || 3000); |
33 | app.use(require('morgan')('dev')); | 33 | app.use(require('morgan')('dev')); |
34 | app.use(require('body-parser').urlencoded({extended:true})); | 34 | app.use(require('body-parser').urlencoded({extended:true})); |
35 | app.use(require('cookie-parser')('your secret here')); | 35 | app.use(require('cookie-parser')('your secret here')); |
36 | app.use(require('express-session')({secret:'99 little bugs in the code', key:'sid', store: clipperz.session_store(), resave: false, saveUninitialized: false })); | 36 | app.use(require('express-session')({secret:'99 little bugs in the code', key:'sid', store: clipperz.session_store(), resave: false, saveUninitialized: false })); |
37 | 37 | ||
38 | app.post('/json',clipperz.json); | 38 | /* Like this: */ |
39 | app.get('/dump',clipperz.dump); | 39 | app.use(clipperz.router); |
40 | /* Or this: */ | ||
41 | app.use('/clz/',clipperz.router); | ||
40 | 42 | ||
41 | app.use(EXPRESS.static(PATH.join(__dirname, 'htdocs/'))); | ||
42 | if ('development' == app.get('env')) { | 43 | if ('development' == app.get('env')) { |
43 | app.use(require('express-error-with-sources')()); | 44 | app.use(require('express-error-with-sources')()); |
44 | } | 45 | } |
45 | 46 | ||
46 | 47 | ||
47 | 48 | ||
diff --git a/backend/node/src/clipperz.js b/backend/node/src/clipperz.js index 842de31..2a3df73 100644 --- a/backend/node/src/clipperz.js +++ b/backend/node/src/clipperz.js | |||
@@ -1,10 +1,12 @@ | |||
1 | var FS = require('fs'); | 1 | var FS = require('fs'); |
2 | var CRYPTO = require('crypto'); | 2 | var CRYPTO = require('crypto'); |
3 | var BIGNUM = require('bignum'); | 3 | var BIGNUM = require('bignum'); |
4 | var ASYNC = require('async'); | 4 | var ASYNC = require('async'); |
5 | var EXPRESS = require('express'); | ||
6 | var PATH = require('path'); | ||
5 | 7 | ||
6 | var express_store = require('express-session').Store; | 8 | var express_store = require('express-session').Store; |
7 | 9 | ||
8 | function clipperz_hash(v) { | 10 | function clipperz_hash(v) { |
9 | return CRYPTO.createHash('sha256').update( | 11 | return CRYPTO.createHash('sha256').update( |
10 | CRYPTO.createHash('sha256').update(v).digest('binary') | 12 | CRYPTO.createHash('sha256').update(v).digest('binary') |
@@ -576,9 +578,13 @@ var CLIPPERZ = module.exports = function(CONFIG) { | |||
576 | }); | 578 | }); |
577 | } | 579 | } |
578 | 580 | ||
579 | }; | 581 | }; |
580 | rv.__defineGetter__('session_store',function(){ return function(o) { return new (clipperz_store(PG))(o) } }); | 582 | rv.__defineGetter__('session_store',function(){ return function(o) { return new (clipperz_store(PG))(o) } }); |
581 | 583 | ||
584 | (rv.router = require('express').Router()) | ||
585 | .post('/json',rv.json).get('/dump',rv.dump) | ||
586 | .use(EXPRESS.static(PATH.join(__dirname,'htdocs/'))); | ||
587 | |||
582 | return rv; | 588 | return rv; |
583 | 589 | ||
584 | }; | 590 | }; |