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

30 lines
889 B
JavaScript
Raw Normal View History

2017-10-09 22:01:02 -04:00
var index = require('./routes/index.js');
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 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);
app.use('/v', view);
app.use('/upload', 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 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});
}
})
};