use router for relative path

v1.18.x
barisusakli 11 years ago
parent 38494a2af0
commit ec1196d288

@ -373,8 +373,6 @@ accountsController.accountSettings = function(req, res, next) {
};
accountsController.uploadPicture = function (req, res, next) {
console.log(req.body, req.files);
var uploadSize = parseInt(meta.config.maximumProfileImageSize, 10) || 256;
if (req.files.userPhoto.size > uploadSize * 1024) {
fs.unlink(req.files.userPhoto.path);

@ -181,6 +181,7 @@ function getRecentPosts(req, res, next) {
module.exports = function(app, middleware, controllers) {
var router = express.Router();
app.use('/api', router);
router.get('/config', controllers.api.getConfig);
@ -193,5 +194,4 @@ module.exports = function(app, middleware, controllers) {
router.post('/topic/thumb/upload', uploadThumb);
router.post('/user/:userslug/uploadpicture', middleware.authenticate, middleware.checkGlobalPrivacySettings, middleware.checkAccountPermissions, controllers.accounts.uploadPicture);
app.use('/api', router);
};

@ -8,7 +8,7 @@ var express = require('express'),
module.exports = function(app, middleware, controllers) {
var router = express.Router();
app.use('/debug', router);
router.get('/uid/:uid', function (req, res) {
if (!req.params.uid) {
return res.redirect('/404');
@ -58,6 +58,4 @@ module.exports = function(app, middleware, controllers) {
router.get('/test', function(req, res) {
res.redirect('404');
});
return router;
};

@ -155,44 +155,45 @@ function groupRoutes(app, middleware, controllers) {
module.exports = function(app, middleware) {
var router = express.Router();
app.use(nconf.get('relative_path'), router);
plugins.ready(function() {
app.all('/api/*', middleware.updateLastOnlineTime, middleware.prepareAPI);
app.all('/api/admin/*', middleware.admin.isAdmin, middleware.prepareAPI);
app.all('/admin/*', middleware.admin.isAdmin);
app.get('/admin', middleware.admin.isAdmin);
router.all('/api/*', middleware.updateLastOnlineTime, middleware.prepareAPI);
router.all('/api/admin/*', middleware.admin.isAdmin, middleware.prepareAPI);
router.all('/admin/*', middleware.admin.isAdmin);
router.get('/admin', middleware.admin.isAdmin);
plugins.fireHook('action:app.load', app, middleware, controllers);
plugins.fireHook('action:app.load', router, middleware, controllers);
adminRoutes(app, middleware, controllers);
metaRoutes(app, middleware, controllers);
apiRoutes(app, middleware, controllers);
feedRoutes(app, middleware, controllers);
pluginRoutes(app, middleware, controllers);
authRoutes.createRoutes(app, middleware, controllers);
adminRoutes(router, middleware, controllers);
metaRoutes(router, middleware, controllers);
apiRoutes(router, middleware, controllers);
feedRoutes(router, middleware, controllers);
pluginRoutes(router, middleware, controllers);
authRoutes.createRoutes(router, middleware, controllers);
/**
* Every view has an associated API route.
*
*/
mainRoutes(app, middleware, controllers);
staticRoutes(app, middleware, controllers);
topicRoutes(app, middleware, controllers);
tagRoutes(app, middleware, controllers);
categoryRoutes(app, middleware, controllers);
accountRoutes(app, middleware, controllers);
userRoutes(app, middleware, controllers);
groupRoutes(app, middleware, controllers);
mainRoutes(router, middleware, controllers);
staticRoutes(router, middleware, controllers);
topicRoutes(router, middleware, controllers);
tagRoutes(router, middleware, controllers);
categoryRoutes(router, middleware, controllers);
accountRoutes(router, middleware, controllers);
userRoutes(router, middleware, controllers);
groupRoutes(router, middleware, controllers);
app.use(nconf.get('relative_path'), router);
app.use(catch404);
app.use(handleErrors);
});
if (process.env.NODE_ENV === 'development') {
app.use('/debug', require('./debug')(middleware, controllers));
require('./debug')(app, middleware, controllers);
}
};

Loading…
Cancel
Save