Skip to content

Commit

Permalink
Align with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
reginaldbondoc committed Dec 21, 2022
1 parent 75e3a3b commit a3609b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 0 additions & 1 deletion .github/workflows/check-be-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: "Check Backend Pull Request"

on:
workflow_dispatch: # remove me
pull_request:
types: [opened, synchronize]
paths:
Expand Down
7 changes: 1 addition & 6 deletions backend/src/services/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ export const initDatabase = (MONGO_URL: string) => {
mongoose
.connect(MONGO_URL)
.then(() => console.log('Successfully connected to DB'))
.catch((e) => {
console.log('Failed to connect to DB ', e);
setTimeout(() => {
console.log(e);
}, 5000);
});
.catch((e) => console.log('Failed to connect to DB ', e));
return mongoose.connection;
};
12 changes: 6 additions & 6 deletions backend/src/services/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export const setUpHealthEndpoint = <T>(server: T) => {
const onSignal = () => {
console.log('Server is starting clean-up');
return Promise.all([
() => {
new Promise((resolve) => {
if (mongoose.connection && mongoose.connection.readyState == 1) {
mongoose.connection.close();
() => {
console.info('Database connection closed');
};
mongoose.connection.close()
.then(() => resolve('Database connection closed'));
} else {
resolve('Database connection already closed');
}
}
})
]);
};

Expand Down

0 comments on commit a3609b9

Please sign in to comment.