diff --git a/server/app.ts b/server/app.ts index 66ce8373..64066f32 100644 --- a/server/app.ts +++ b/server/app.ts @@ -33,8 +33,8 @@ app.use(cookieParser()); passportConfig(passport); -app.use(path.join(paths.servedPath, 'api'), apiRoutes); -app.use(path.join(paths.servedPath, 'auth'), authRoutes); +app.use(`${paths.servedPath}api`, apiRoutes); +app.use(`${paths.servedPath}auth`, authRoutes); // After routes, look for static assets. app.use(paths.servedPath, express.static(paths.appDist)); @@ -42,15 +42,15 @@ app.use(paths.servedPath, express.static(paths.appDist)); // Client app routes, serve index.html and client js will figure it out const html = fs.readFileSync(path.join(paths.appDist, 'index.html'), {encoding: 'utf8'}); -app.get(path.join(paths.servedPath, 'login'), (_req, res) => { +app.get(`${paths.servedPath}login`, (_req, res) => { res.send(html); }); -app.get(path.join(paths.servedPath, 'register'), (_req, res) => { +app.get(`${paths.servedPath}register`, (_req, res) => { res.send(html); }); -app.get(path.join(paths.servedPath, 'overview'), (_req, res) => { +app.get(`${paths.servedPath}overview`, (_req, res) => { res.send(html); }); diff --git a/shared/config/paths.d.ts b/shared/config/paths.d.ts new file mode 100644 index 00000000..cc397b3c --- /dev/null +++ b/shared/config/paths.d.ts @@ -0,0 +1,15 @@ +declare const PATHS: { + appBuild: string; + appDist: string; + appPublic: string; + appHtml: string; + appIndex: string; + appPackageJson: string; + appSrc: string; + clientSrc: string; + testsSetup: string; + appNodeModules: string; + servedPath: string; +}; + +export = PATHS; diff --git a/shared/config/paths.js b/shared/config/paths.js index 8e74bbf2..33a54613 100644 --- a/shared/config/paths.js +++ b/shared/config/paths.js @@ -30,7 +30,7 @@ const getAppDist = () => { return appDist; }; -module.exports = { +const PATHS = { appBuild: resolveApp('dist/assets'), appDist: getAppDist(), appPublic: resolveApp('client/src/public/'), @@ -43,3 +43,5 @@ module.exports = { appNodeModules: resolveApp('node_modules'), servedPath: ensureSlash(userConfig.baseURI || '/', true), }; + +module.exports = PATHS;