]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blame_incremental - app.js
Fix session serialization
[perso/Immae/Projets/Nodejs/Surfer.git] / app.js
... / ...
CommitLineData
1#!/usr/bin/env node
2
3'use strict';
4
5var express = require('express'),
6 morgan = require('morgan'),
7 passport = require('passport'),
8 path = require('path'),
9 compression = require('compression'),
10 session = require('express-session'),
11 bodyParser = require('body-parser'),
12 cookieParser = require('cookie-parser'),
13 lastMile = require('connect-lastmile'),
14 multipart = require('./src/multipart'),
15 auth = require('./src/auth.js'),
16 files = require('./src/files.js')(path.resolve(__dirname, 'files'));
17
18var app = express();
19var router = new express.Router();
20
21var multipart = multipart({ maxFieldsSize: 2 * 1024, limit: '512mb', timeout: 3 * 60 * 1000 });
22
23router.get('/api/files/*', auth.ldap, files.get);
24router.put('/api/files/*', auth.ldap, multipart, files.put);
25router.delete('/api/files/*', auth.ldap, files.del);
26
27// healthcheck in case / does not serve up any file yet
28router.get('/', function (req, res) { res.sendFile(path.join(__dirname, '/app/welcome.html')); });
29
30app.use(morgan('dev'));
31app.use(compression());
32app.use('/settings', express.static(__dirname + '/app'));
33app.use(express.static(__dirname + '/files'));
34app.use(bodyParser.json());
35app.use(bodyParser.urlencoded());
36app.use(cookieParser());
37app.use(session({ secret: 'surfin surfin' }));
38app.use(passport.initialize());
39app.use(passport.session());
40app.use(router);
41app.use(lastMile());
42
43var server = app.listen(3000, function () {
44 var host = server.address().address;
45 var port = server.address().port;
46
47 console.log('Surfer listening at http://%s:%s', host, port);
48});