Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import poolRoutes from "./routes/pool";
import stateRoutes from "./routes/state";
import { pool } from "./config/db";
import { startStorageCleanup, stopStorageCleanup } from "./utils/storage-cleanup";
import { startNonceCleanup, stopNonceCleanup } from "./utils/nonce-cleanup";

dotenv.config();

Expand Down Expand Up @@ -151,6 +152,7 @@ app.get("/health", async (req: Request, res: Response) => {
process.on("SIGTERM", async () => {
logger.info("SIGTERM received, shutting down gracefully");
stopStorageCleanup();
stopNonceCleanup();
try {
await prisma.$disconnect();
logger.info("Database connection closed");
Expand All @@ -172,6 +174,7 @@ async function bootstrap(): Promise<void> {
await connectWithRetry();
startPoolHealthCheck();
startStorageCleanup();
startNonceCleanup();
app.listen(port, () => {
console.log(`⚡️[server]: Server is running at http://localhost:${port}`);
// Update pool metrics periodically so the Prometheus scrape has fresh data
Expand Down
5 changes: 3 additions & 2 deletions backend/src/middleware/authGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ export async function authGuard(
res: Response,
next: NextFunction
): Promise<void> {
// Try to get token from cookie first, then from Authorization header
let token = req.cookies[ACCESS_TOKEN_COOKIE];
// Try to get token from cookie first (cookie-parser adds req.cookies;
// when unavailable, skip gracefully), then from Authorization header.
let token = req.cookies?.[ACCESS_TOKEN_COOKIE];
const header = req.headers.authorization;
if (!token && header?.startsWith("Bearer ")) {
token = header.slice(7);
Expand Down
Loading
Loading