Skip to content

Commit

Permalink
Merge pull request #119 from AsliSema/db-conn-deploy-test
Browse files Browse the repository at this point in the history
testing db conn
  • Loading branch information
nourkrimesh authored Aug 10, 2023
2 parents 9b90864 83d77dd commit 61f1841
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ app.all('*', (req: Request, res: Response, next: NextFunction) => {
app.use(errorHandlerMiddleware);

export const server = app.listen(config.server.port, () => {
console.log(`Server is running at http://localhost:${config.server.port}`);
console.log(`The Server is running at http://localhost:${config.server.port}`);
});

// handle rejections outside express eg: database errors etc..
Expand Down
16 changes: 9 additions & 7 deletions src/db/connection.ts
Original file line number Diff line number Diff line change
@@ -1,18 1,20 @@
import { config } from '../config/config';
import mongoose, { ConnectOptions } from 'mongoose';

let mongoURI;

if (config.environment === 'development') {
mongoURI = config.mongo.devDB.url;
} else if (config.environment === 'test') {
mongoURI = config.mongo.testDB.url;
}

const connectToDatabase = async () => {
let mongoURI;

if (config.environment === 'development') {
mongoURI = config.mongo.devDB.url;
} else if (config.environment === 'test') {
mongoURI = config.mongo.testDB.url;
}
console.log('1: trying to connect to database with connStr:', mongoURI);
if (mongoURI !== undefined) {
try {
console.log('trying to connect to database with connStr:', mongoURI);
console.log('2: trying to connect to database with connStr:', mongoURI);
await mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
Expand Down

0 comments on commit 61f1841

Please sign in to comment.