aboutsummaryrefslogtreecommitdiff
path: root/src/routes.ts
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2020-04-27 18:17:06 -0400
committerKevin J Hoerr <kjhoerr@protonmail.com>2020-04-27 18:17:06 -0400
commitfd2013a7bf4129b05080f01ef199d69b9ef9ec68 (patch)
tree8f8eae08b2884a0e066e01138aa6a104625d952f /src/routes.ts
parent32db5f6e5e8b6f6d2baffbec44cc34daedd24533 (diff)
downloadao-coverage-fd2013a7bf4129b05080f01ef199d69b9ef9ec68.tar.gz
ao-coverage-fd2013a7bf4129b05080f01ef199d69b9ef9ec68.tar.bz2
ao-coverage-fd2013a7bf4129b05080f01ef199d69b9ef9ec68.zip
Refactor startup to passthrough values
Even more refactoring - however there were some small troubles using path in the nested scripts/files, so referencing them via the index should be a bit more stable. Plus, the config unit tests won't just exit because of configOrError constants strewn about the file.
Diffstat (limited to 'src/routes.ts')
-rw-r--r--src/routes.ts13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/routes.ts b/src/routes.ts
index 7ebb610..98260fa 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -17,7 +17,7 @@ const HOST_DIR = configOrError("HOST_DIR");
const logger = winston.createLogger(loggerConfig("HTTP"));
-export default (metadata: Metadata): Router => {
+export default (metadata: Metadata, publicPath: string): Router => {
const router = Router();
// serve landing page
@@ -33,15 +33,12 @@ export default (metadata: Metadata): Router => {
})
);
- // serve static files
// favicon should be served directly on root
router.get("/favicon.ico", (_, res) => {
- res.sendFile(path.join(__dirname, "..", "public", "static", "favicon.ico"));
+ res.sendFile(path.join(publicPath, "static", "favicon.ico"));
});
- router.use(
- "/static",
- express.static(path.join(__dirname, "..", "public", "static"))
- );
+ // serve static files
+ router.use("/static", express.static(path.join(publicPath, "static")));
// Upload HTML file
router.post("/v1/:org/:repo/:branch/:commit.html", (req, res) => {
@@ -219,7 +216,7 @@ export default (metadata: Metadata): Router => {
router.use((_, res) => {
res.status(404);
- res.sendFile(path.join(__dirname, "..", "public", "static", "404.html"));
+ res.sendFile(path.join(publicPath, "static", "404.html"));
});
return router;