feat: initialize MinIO bucket on server start and log status

This commit is contained in:
2025-12-11 14:30:00 +00:00
parent bd3d17c192
commit cae15f3f7d
2 changed files with 16 additions and 3 deletions

View File

@@ -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, () => {
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();

View File

@@ -38,6 +38,7 @@ export const ensureMinioBucket = async (): Promise<void> => {
try {
await ensureBucketPromise;
console.log("Minio Up")
} catch (error) {
ensureBucketPromise = null;
throw error;