Skip to content

Commit

Permalink
--
Browse files Browse the repository at this point in the history
  • Loading branch information
jipsonminibhavan committed Feb 8, 2024
1 parent 432c9d7 commit 34c38c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class App {
this.initializeMiddleware();
this.initializePassport();
this.initializeRoutes(routes);
this.databaseConnection();
this.initializeDB();
}
private initializeMiddleware(): void {
this.app.use(cors());
Expand Down Expand Up @@ -48,13 +48,16 @@ class App {
});
}

private async databaseConnection(): Promise<void> {
private async initializeDB(): Promise<void> {
try {
await connectToDB();
console.log("Database connection successful");
} catch (error) {
console.error("MongoDB connection error:", error);
throw new Error("Database connection failed");
}
}

public listen(): void {
this.app.listen(config.PORT, () => {
console.log(`Server on Port ${config.PORT}`);
Expand Down

0 comments on commit 34c38c4

Please sign in to comment.