1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-10 23:53:31 -05:00
shimapan/app/routes.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-10-09 22:01:02 -04:00
var index = require('./routes/index.js');
2017-10-14 15:16:58 -04:00
var home = require('./routes/home.js');
2017-10-09 22:01:02 -04:00
var upload = require('./routes/upload.js');
var view = require('./routes/view.js');
2017-10-11 10:15:19 -04:00
var auth = require('./routes/auth.js');
var register = require('./routes/register.js');
2017-10-11 13:11:57 -04:00
var login = require('./routes/login.js');
2017-10-11 20:26:07 -04:00
var panel = require('./routes/panel');
2017-10-11 10:15:19 -04:00
var fs = require('fs');
var path = require('path');
var jwt = require('express-jwt');
var jwtauth = jwt({
secret: fs.readFileSync(path.join(__dirname, '../jwt.pem'), 'utf8'),
userProperty: 'payload'
});
2017-10-09 22:01:02 -04:00
module.exports = function(app) {
app.use('/', index);
2017-10-14 15:16:58 -04:00
app.use('/home', home);
2017-10-09 22:01:02 -04:00
app.use('/v', view);
2017-10-11 20:26:07 -04:00
app.use('/api/upload', jwtauth, upload);
2017-10-11 10:15:19 -04:00
app.use('/api/auth', auth);
app.use('/register', register);
2017-10-11 13:11:57 -04:00
app.use('/login', login);
2017-10-11 20:26:07 -04:00
app.use('/panel', panel);
app.use('/panel*', 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});
}
})
};