From cae15f3f7d31e0d3e9fca5008e08f6679c826be8 Mon Sep 17 00:00:00 2001 From: Matiss Jurevics Date: Thu, 11 Dec 2025 14:30:00 +0000 Subject: [PATCH] feat: initialize MinIO bucket on server start and log status --- Backend/index.ts | 18 +++++++++++++++--- Backend/utils/minio.ts | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Backend/index.ts b/Backend/index.ts index 810f528..6f50cb9 100644 --- a/Backend/index.ts +++ b/Backend/index.ts @@ -3,6 +3,7 @@ import express from 'express'; import authRoutes from './routes/auth'; import videosRoutes from './routes/videos'; +import { ensureMinioBucket } from './utils/minio'; const app = express(); @@ -22,6 +23,17 @@ app.use((err: unknown, _req: express.Request, res: express.Response, _next: expr const port = Number(process.env.PORT ?? 3000); -app.listen(port, () => { - console.log(`Server is running on port ${port}`); -}); +const start = async () => { + try { + await ensureMinioBucket(); + } catch (error) { + console.error('MinIO initialization failed', error); + process.exit(1); + } + + app.listen(port, () => { + console.log(`Server is running on port ${port}`); + }); +}; + +start(); diff --git a/Backend/utils/minio.ts b/Backend/utils/minio.ts index 33055d3..03f0fe8 100644 --- a/Backend/utils/minio.ts +++ b/Backend/utils/minio.ts @@ -38,6 +38,7 @@ export const ensureMinioBucket = async (): Promise => { try { await ensureBucketPromise; + console.log("Minio Up") } catch (error) { ensureBucketPromise = null; throw error;