2017-10-20 16:46:14 -04:00
|
|
|
var index = require('./index.js');
|
|
|
|
var home = require('./home.js');
|
|
|
|
var upload = require('./upload.js');
|
|
|
|
var view = require('./view.js');
|
|
|
|
var auth = require('./auth.js');
|
|
|
|
var register = require('./register.js');
|
|
|
|
var login = require('./login.js');
|
|
|
|
var panel = require('./panel.js');
|
|
|
|
var keys = require('./keys.js');
|
2017-10-11 10:15:19 -04:00
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
2017-10-14 17:49:11 -04:00
|
|
|
|
2017-10-18 13:31:08 -04:00
|
|
|
var requireLogin = function(req, res, next) {
|
|
|
|
if (!req.session.passport.user)
|
|
|
|
res.redirect('/login');
|
|
|
|
else
|
|
|
|
next();
|
|
|
|
};
|
2017-10-09 22:01:02 -04:00
|
|
|
|
|
|
|
module.exports = function(app) {
|
|
|
|
app.use('/', index);
|
2017-10-18 13:31:08 -04:00
|
|
|
app.use('/home', requireLogin, home);
|
2017-10-09 22:01:02 -04:00
|
|
|
app.use('/v', view);
|
2017-10-18 13:31:08 -04:00
|
|
|
app.use('/api/upload', upload);
|
2017-10-11 10:15:19 -04:00
|
|
|
app.use('/api/auth', auth);
|
2017-10-18 13:31:08 -04:00
|
|
|
app.use('/api/keys', requireLogin, keys);
|
2017-10-11 10:15:19 -04:00
|
|
|
app.use('/register', register);
|
2017-10-11 13:11:57 -04:00
|
|
|
app.use('/login', login);
|
2017-10-18 13:31:08 -04:00
|
|
|
app.use('/panel', requireLogin, panel);
|
|
|
|
app.use('/panel*', requireLogin, panel);
|
2017-10-11 10:15:19 -04:00
|
|
|
|
|
|
|
app.use(function(err, req, res, next) {
|
|
|
|
if (err.name === 'UnauthorizedError') {
|
|
|
|
res.status(401);
|
|
|
|
res.json({"message": err.name + ": " + err.message});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|