CSOL-site/app.js

33 строки
996 B
JavaScript
Исходник Обычный вид История

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();
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());
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-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);
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);