@ -1,7 +1,7 @@
let doSetup = null ;
let doSetup = null ;
try {
try {
// Check if config.json exists
// Check if config.json exists
require ( '. /config.json') ;
require ( '. . /config.json') ;
} catch ( err ) {
} catch ( err ) {
doSetup = require ( './setup' ) . doSetup ;
doSetup = require ( './setup' ) . doSetup ;
}
}
@ -13,7 +13,7 @@ if (doSetup) {
}
}
// Load the config
// Load the config
const { host , port , useSsl , isProxied , s3enabled , frontendName , indexFile } = require ( '. /config.json') ;
const { host , port , useSsl , isProxied , s3enabled , frontendName , indexFile } = require ( '. . /config.json') ;
//#region Imports
//#region Imports
const fs = require ( 'fs-extra' ) ;
const fs = require ( 'fs-extra' ) ;
@ -24,8 +24,8 @@ const marked = require('marked');
const uploadRouter = require ( './routers/upload' ) ;
const uploadRouter = require ( './routers/upload' ) ;
const resourceRouter = require ( './routers/resource' ) ;
const resourceRouter = require ( './routers/resource' ) ;
const { path , log , getTrueHttp , getTrueDomain } = require ( './utils' ) ;
const { path , log , getTrueHttp , getTrueDomain } = require ( './utils' ) ;
const { CODE _INTERNAL _SERVER _ERROR } = require ( '. /MagicNumbers.json') ;
const { CODE _INTERNAL _SERVER _ERROR } = require ( '. . /MagicNumbers.json') ;
const { name : ASS _NAME , version : ASS _VERSION } = require ( '. /package.json') ;
const { name : ASS _NAME , version : ASS _VERSION } = require ( '. . /package.json') ;
//#endregion
//#endregion
// Welcome :D
// Welcome :D
@ -66,7 +66,7 @@ useSsl && app.use(helmet.hsts({ preload: true })); // skipcq: JS-0093
app . use ( nofavicon ) ;
app . use ( nofavicon ) ;
// Use custom index, otherwise render README.md
// Use custom index, otherwise render README.md
const ASS _INDEX = indexFile !== '' && fs . existsSync ( ` . /${ indexFile } ` ) && require ( ` ./${ indexFile } ` ) ;
const ASS _INDEX = indexFile !== '' && fs . existsSync ( ` . . /${ indexFile } ` ) && require ( ` . ./${ indexFile } ` ) ;
app . get ( '/' , ( req , res , next ) => ASS _INDEX // skipcq: JS-0229
app . get ( '/' , ( req , res , next ) => ASS _INDEX // skipcq: JS-0229
? ASS _INDEX ( req , res , next )
? ASS _INDEX ( req , res , next )
: fs . readFile ( path ( 'README.md' ) )
: fs . readFile ( path ( 'README.md' ) )
@ -79,7 +79,7 @@ app.get('/', (req, res, next) => ASS_INDEX // skipcq: JS-0229
app . use ( '/' , ROUTERS . upload ) ;
app . use ( '/' , ROUTERS . upload ) ;
// Set up custom frontend
// Set up custom frontend
const ASS _FRONTEND = fs . existsSync ( ` ./ ${ frontendName } /package.json ` ) ? ( require ( 'submodule' ) , require ( ` ./${ frontendName } ` ) ) : { enabled : false } ;
const ASS _FRONTEND = fs . existsSync ( path ( ` ./ ${ frontendName } /package.json ` ) ) ? ( require ( 'submodule' ) , require ( ` . ./${ frontendName } ` ) ) : { enabled : false } ; // todo: update with src/
ASS _FRONTEND . enabled && app . use ( ASS _FRONTEND . endpoint , ASS _FRONTEND . router ) ; // skipcq: JS-0093
ASS _FRONTEND . enabled && app . use ( ASS _FRONTEND . endpoint , ASS _FRONTEND . router ) ; // skipcq: JS-0093
// '/:resouceId' always needs to be LAST since it's a catch-all route
// '/:resouceId' always needs to be LAST since it's a catch-all route