You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
981 B

const nunjucks = require('nunjucks');
const express = require('express');
const nunjucksFilters = require('./lib/nunjucks-filters');
const nunjucksMiddleware = require('./lib/nunjucks-middleware');
const compression = require('compression');
8 years ago
const minify = require('./lib/minify');
const controllers = require('./controllers');
const app = express();
const port = process.env.port || 3000;
8 years ago
// Setup nunjucks
nunjucks.configure('views', { express: app });
nunjucksFilters(app);
app.use(nunjucksMiddleware);
// Compress responses
app.use(compression());
8 years ago
// Minify responses
app.use(minify);
8 years ago
// Page routes
app.get('/', controllers.listing);
app.get('/node/:id', controllers.node);
// Serve assets with cache headers
app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: '1 year' }));
8 years ago
// Start app
app.listen(port, () => console.log(`Tor Explorer listening on port ${port}`));