feat: initialize MinIO bucket on server start and log status
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -38,6 +38,7 @@ export const ensureMinioBucket = async (): Promise<void> => {
|
||||
|
||||
try {
|
||||
await ensureBucketPromise;
|
||||
console.log("Minio Up")
|
||||
} catch (error) {
|
||||
ensureBucketPromise = null;
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user