Improve log and GH token validation

This commit is contained in:
tdurieux
2024-04-27 16:19:33 +01:00
parent 6476899764
commit 2a145730b7
4 changed files with 27 additions and 10 deletions

View File

@@ -130,6 +130,23 @@ export default async function start() {
keyGenerator,
});
app.use(
express.static(join("public"), {
etag: true,
lastModified: true,
maxAge: 3600, // 1h
})
);
app.use(function (req, res, next) {
const start = Date.now();
res.on("finish", function () {
const time = Date.now() - start;
console.log(`${req.method} ${join(req.baseUrl, req.url)} ${time}ms`);
});
next();
});
app.use("/github", rate, speedLimiter, connectionRouter);
// api routes
@@ -201,14 +218,6 @@ export default async function start() {
.get("/r/:repoId/?*", indexResponse)
.get("/repository/:repoId/?*", indexResponse);
app.use(
express.static(join("public"), {
etag: true,
lastModified: true,
maxAge: 3600, // 1h
})
);
app.get("*", indexResponse);
// start schedules

View File

@@ -58,8 +58,8 @@ router.get(
// cache the file for 5min
res.header("Cache-Control", "max-age=300");
}
await repo.countView();
await f.send(res);
await repo.countView();
} catch (error) {
return handleError(error, res, req);
}