@ -1,27 +1,27 @@
'use strict' ;
'use strict' ;
var nconf = require ( 'nconf' ) ;
const nconf = require ( 'nconf' ) ;
var winston = require ( 'winston' ) ;
const winston = require ( 'winston' ) ;
var path = require ( 'path' ) ;
const path = require ( 'path' ) ;
var express = require ( 'express' ) ;
const express = require ( 'express' ) ;
var meta = require ( '../meta' ) ;
const meta = require ( '../meta' ) ;
var controllers = require ( '../controllers' ) ;
const controllers = require ( '../controllers' ) ;
var plugins = require ( '../plugins' ) ;
const plugins = require ( '../plugins' ) ;
var accountRoutes = require ( './accounts' ) ;
const accountRoutes = require ( './accounts' ) ;
var metaRoutes = require ( './meta' ) ;
const metaRoutes = require ( './meta' ) ;
var apiRoutes = require ( './api' ) ;
const apiRoutes = require ( './api' ) ;
var adminRoutes = require ( './admin' ) ;
const adminRoutes = require ( './admin' ) ;
var feedRoutes = require ( './feeds' ) ;
const feedRoutes = require ( './feeds' ) ;
var authRoutes = require ( './authentication' ) ;
const authRoutes = require ( './authentication' ) ;
const writeRoutes = require ( './write' ) ;
const writeRoutes = require ( './write' ) ;
var helpers = require ( './helpers' ) ;
const helpers = require ( './helpers' ) ;
var setupPageRoute = helpers . setupPageRoute ;
const setupPageRoute = helpers . setupPageRoute ;
function mainRoutes ( app , middleware , controllers ) {
function mainRoutes ( app , middleware , controllers ) {
var loginRegisterMiddleware = [ middleware . redirectToAccountIfLoggedIn ] ;
const loginRegisterMiddleware = [ middleware . redirectToAccountIfLoggedIn ] ;
setupPageRoute ( app , '/login' , middleware , loginRegisterMiddleware , controllers . login ) ;
setupPageRoute ( app , '/login' , middleware , loginRegisterMiddleware , controllers . login ) ;
setupPageRoute ( app , '/register' , middleware , loginRegisterMiddleware , controllers . register ) ;
setupPageRoute ( app , '/register' , middleware , loginRegisterMiddleware , controllers . register ) ;
@ -78,13 +78,13 @@ function categoryRoutes(app, middleware, controllers) {
}
}
function userRoutes ( app , middleware , controllers ) {
function userRoutes ( app , middleware , controllers ) {
var middlewares = [ middleware . canViewUsers ] ;
const middlewares = [ middleware . canViewUsers ] ;
setupPageRoute ( app , '/users' , middleware , middlewares , controllers . users . index ) ;
setupPageRoute ( app , '/users' , middleware , middlewares , controllers . users . index ) ;
}
}
function groupRoutes ( app , middleware , controllers ) {
function groupRoutes ( app , middleware , controllers ) {
var middlewares = [ middleware . canViewGroups ] ;
const middlewares = [ middleware . canViewGroups ] ;
setupPageRoute ( app , '/groups' , middleware , middlewares , controllers . groups . list ) ;
setupPageRoute ( app , '/groups' , middleware , middlewares , controllers . groups . list ) ;
setupPageRoute ( app , '/groups/:slug' , middleware , middlewares , controllers . groups . details ) ;
setupPageRoute ( app , '/groups/:slug' , middleware , middlewares , controllers . groups . details ) ;
@ -96,7 +96,7 @@ module.exports = async function (app, middleware) {
router . render = function ( ) {
router . render = function ( ) {
app . render . apply ( app , arguments ) ;
app . render . apply ( app , arguments ) ;
} ;
} ;
var ensureLoggedIn = require ( 'connect-ensure-login' ) ;
const ensureLoggedIn = require ( 'connect-ensure-login' ) ;
router . all ( '(/+api|/+api/*?)' , middleware . prepareAPI ) ;
router . all ( '(/+api|/+api/*?)' , middleware . prepareAPI ) ;
router . all ( '(/+api/admin|/+api/admin/*?)' , middleware . authenticate , middleware . admin . checkPrivileges ) ;
router . all ( '(/+api/admin|/+api/admin/*?)' , middleware . authenticate , middleware . admin . checkPrivileges ) ;
@ -135,7 +135,7 @@ function addCoreRoutes(app, router, middleware) {
userRoutes ( router , middleware , controllers ) ;
userRoutes ( router , middleware , controllers ) ;
groupRoutes ( router , middleware , controllers ) ;
groupRoutes ( router , middleware , controllers ) ;
var relativePath = nconf . get ( 'relative_path' ) ;
const relativePath = nconf . get ( 'relative_path' ) ;
app . use ( relativePath || '/' , router ) ;
app . use ( relativePath || '/' , router ) ;
if ( process . env . NODE _ENV === 'development' ) {
if ( process . env . NODE _ENV === 'development' ) {
@ -144,12 +144,12 @@ function addCoreRoutes(app, router, middleware) {
app . use ( middleware . privateUploads ) ;
app . use ( middleware . privateUploads ) ;
var statics = [
const statics = [
{ route : '/assets' , path : path . join ( _ _dirname , '../../build/public' ) } ,
{ route : '/assets' , path : path . join ( _ _dirname , '../../build/public' ) } ,
{ route : '/assets' , path : path . join ( _ _dirname , '../../public' ) } ,
{ route : '/assets' , path : path . join ( _ _dirname , '../../public' ) } ,
{ route : '/plugins' , path : path . join ( _ _dirname , '../../build/public/plugins' ) } ,
{ route : '/plugins' , path : path . join ( _ _dirname , '../../build/public/plugins' ) } ,
] ;
] ;
var staticOptions = {
const staticOptions = {
maxAge : app . enabled ( 'cache' ) ? 5184000000 : 0 ,
maxAge : app . enabled ( 'cache' ) ? 5184000000 : 0 ,
} ;
} ;