Skip to content

Commit

Permalink
Merge pull request #11 from shinevue/feature/deploy-vercel
Browse files Browse the repository at this point in the history
Fix: modify db connection URL
  • Loading branch information
shinevue authored Nov 19, 2024
2 parents 5543a4c + d470491 commit f89162d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# APP ENVIRONMENT VARIABLES
APP_NAME =
APP_NAME = FinalGoal-Backend
APP_PORT = 4000
APP_BASE_URL =
APP_API_PREFIX =

# DB ENVIRONMENT VARIABLES
MONGO_URI =
MONGO_URI = mongodb+srv://shine401020:HfX14PbXX7Ob8IDO@articlesystem.gyxcf.mongodb.net/
8 changes: 8 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# APP ENVIRONMENT VARIABLES
APP_NAME =
APP_PORT = 4000
APP_BASE_URL =
APP_API_PREFIX =

# DB ENVIRONMENT VARIABLES
MONGO_URI =
14 changes: 11 additions & 3 deletions server/src/db/connect.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// external modules import
const mongoose = require('mongoose');
const { MongoClient, ServerApiVersion } = require('mongodb');

const connectionString = 'mongodb://localhost:27017/team231';
const connectionString = process.env.MONGO_URI || 'mongodb://localhost:27017/team231';

const client = new MongoClient(connectionString, {
serverApi: {
version: ServerApiVersion.v1,
strict: true,
deprecationErrors: true,
},
});

const connectDatabase = async () => {
try {
await mongoose
await client
.connect(connectionString, {
useNewUrlParser: true,
useUnifiedTopology: true,
Expand Down

0 comments on commit f89162d

Please sign in to comment.