(argv = {})
| 53 | }) |
| 54 | |
| 55 | function createApp (argv = {}) { |
| 56 | // Override default configs (defaults) with passed-in params (argv) |
| 57 | argv = Object.assign({}, defaults, argv) |
| 58 | |
| 59 | argv.host = SolidHost.from(argv) |
| 60 | |
| 61 | argv.resourceMapper = new ResourceMapper({ |
| 62 | rootUrl: argv.serverUri, |
| 63 | rootPath: path.resolve(argv.root || process.cwd()), |
| 64 | includeHost: argv.multiuser, |
| 65 | defaultContentType: argv.defaultContentType |
| 66 | }) |
| 67 | |
| 68 | const configPath = config.initConfigDir(argv) |
| 69 | argv.templates = config.initTemplateDirs(configPath) |
| 70 | |
| 71 | config.printDebugInfo(argv) |
| 72 | |
| 73 | const ldp = new LDP(argv) |
| 74 | |
| 75 | const app = express() |
| 76 | |
| 77 | // Add PREP support |
| 78 | if (argv.prep) { |
| 79 | app.use(eventID) |
| 80 | app.use(acceptEvents, events, prep) |
| 81 | } |
| 82 | |
| 83 | initAppLocals(app, argv, ldp) |
| 84 | initHeaders(app) |
| 85 | initViews(app, configPath) |
| 86 | initLoggers() |
| 87 | |
| 88 | // Serve the public 'common' directory (for shared CSS files, etc) |
| 89 | app.use('/common', express.static(path.join(__dirname, '../common'))) |
| 90 | app.use('/', express.static(path.dirname(fileURLToPath(import.meta.resolve('mashlib/dist/databrowser.html'))), { index: false })) |
| 91 | routeResolvedFile(app, '/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js') |
| 92 | routeResolvedFile(app, '/common/js/', 'solid-auth-client/dist-lib/solid-auth-client.bundle.js.map') |
| 93 | app.use('/.well-known', express.static(path.join(__dirname, '../common/well-known'))) |
| 94 | |
| 95 | // Serve bootstrap from it's node_module directory |
| 96 | routeResolvedFile(app, '/common/css/', 'bootstrap/dist/css/bootstrap.min.css') |
| 97 | routeResolvedFile(app, '/common/css/', 'bootstrap/dist/css/bootstrap.min.css.map') |
| 98 | routeResolvedFile(app, '/common/fonts/', 'bootstrap/dist/fonts/glyphicons-halflings-regular.eot') |
| 99 | routeResolvedFile(app, '/common/fonts/', 'bootstrap/dist/fonts/glyphicons-halflings-regular.svg') |
| 100 | routeResolvedFile(app, '/common/fonts/', 'bootstrap/dist/fonts/glyphicons-halflings-regular.ttf') |
| 101 | routeResolvedFile(app, '/common/fonts/', 'bootstrap/dist/fonts/glyphicons-halflings-regular.woff') |
| 102 | routeResolvedFile(app, '/common/fonts/', 'bootstrap/dist/fonts/glyphicons-halflings-regular.woff2') |
| 103 | |
| 104 | // Serve OWASP password checker from it's node_module directory |
| 105 | routeResolvedFile(app, '/common/js/', 'owasp-password-strength-test/owasp-password-strength-test.js') |
| 106 | // Serve the TextEncoder polyfill |
| 107 | routeResolvedFile(app, '/common/js/', 'text-encoder-lite/text-encoder-lite.min.js') |
| 108 | |
| 109 | // Add CORS proxy |
| 110 | if (argv.proxy) { |
| 111 | console.warn('The proxy configuration option has been renamed to corsProxy.') |
| 112 | argv.corsProxy = argv.corsProxy || argv.proxy |
no test coverage detected