2013-03-25 00:52:09 +04:00
|
|
|
const path = require('path');
|
|
|
|
const http = require('http');
|
|
|
|
const express = require('express');
|
2013-03-25 18:56:30 +04:00
|
|
|
const nunjucks = require('nunjucks');
|
2013-04-23 14:55:46 +04:00
|
|
|
const middleware = require('./middleware');
|
|
|
|
const helpers = require('./helpers');
|
2013-03-25 18:56:30 +04:00
|
|
|
|
2013-04-23 14:55:46 +04:00
|
|
|
const app = express();
|
2013-04-19 13:12:22 +04:00
|
|
|
const env = new nunjucks.Environment(new nunjucks.FileSystemLoader(path.join(__dirname, 'views')), {autoescape: true});
|
2013-03-25 18:56:30 +04:00
|
|
|
env.express(app);
|
2013-03-25 00:52:09 +04:00
|
|
|
|
2013-04-23 14:55:46 +04:00
|
|
|
app.use(express.cookieParser());
|
|
|
|
app.use(middleware.session());
|
2013-03-25 00:52:09 +04:00
|
|
|
app.use(express.logger());
|
|
|
|
app.use(express.compress());
|
|
|
|
app.use(express.bodyParser());
|
2013-04-18 15:11:06 +04:00
|
|
|
app.use(express.csrf());
|
2013-03-25 00:52:09 +04:00
|
|
|
app.use(express.static(path.join(__dirname, 'static')));
|
|
|
|
|
2013-04-23 14:55:46 +04:00
|
|
|
app.use(helpers.addCsrfToken);
|
2013-04-23 15:33:49 +04:00
|
|
|
app.use(helpers.addRangeMethod);
|
2013-04-18 18:33:11 +04:00
|
|
|
|
2013-03-25 00:52:09 +04:00
|
|
|
require('./controllers/auth')(app);
|
|
|
|
require('./controllers/info')(app);
|
|
|
|
require('./controllers/backpack')(app);
|
2013-03-25 18:56:30 +04:00
|
|
|
require('./controllers/program')(app);
|
2013-04-11 15:53:36 +04:00
|
|
|
require('./controllers/learn')(app);
|
2013-04-22 16:36:50 +04:00
|
|
|
require('./controllers/challenges')(app);
|
2013-03-25 00:52:09 +04:00
|
|
|
|
|
|
|
if (!module.parent)
|
|
|
|
app.listen(3000);
|
|
|
|
else
|
|
|
|
module.exports = http.createServer(app);
|