Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I_Helmet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 62
I_Helmet
Commits
15a4d7ab
Commit
15a4d7ab
authored
Apr 26, 2022
by
Balasuriya D.A.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connect Mongo DB to Node js/Express js App
parent
eaeedf50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
IT18021080/Telemedicine-Chat-App/backend/config/db.js
IT18021080/Telemedicine-Chat-App/backend/config/db.js
+22
-0
IT18021080/Telemedicine-Chat-App/backend/server.js
IT18021080/Telemedicine-Chat-App/backend/server.js
+12
-2
No files found.
IT18021080/Telemedicine-Chat-App/backend/config/db.js
0 → 100644
View file @
15a4d7ab
const
mongoose
=
require
(
"
mongoose
"
);
const
connectDB
=
async
()
=>
{
try
{
const
conn
=
await
mongoose
.
connect
(
process
.
env
.
MONGO_URI
,{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
});
console
.
log
(
`MongoDB Connected:
${
conn
.
connection
.
host
}
`
.
cyan
.
underline
);
}
catch
(
error
)
{
console
.
log
(
`Error:
${
error
.
message
}
`
.
red
.
bold
);
process
.
exit
();
}
};
module
.
exports
=
connectDB
;
\ No newline at end of file
IT18021080/Telemedicine-Chat-App/backend/server.js
View file @
15a4d7ab
const
express
=
require
(
"
express
"
);
const
express
=
require
(
"
express
"
);
const
dotenv
=
require
(
"
dotenv
"
);
const
dotenv
=
require
(
"
dotenv
"
);
const
{
chats
}
=
require
(
"
./data/data
"
);
const
{
chats
}
=
require
(
"
./data/data
"
);
const
connectDB
=
require
(
"
./config/db
"
);
const
colors
=
require
(
"
colors
"
);
const
app
=
express
();
dotenv
.
config
();
dotenv
.
config
();
connectDB
();
const
app
=
express
();
app
.
get
(
"
/
"
,
(
req
,
res
)
=>
{
app
.
get
(
"
/
"
,
(
req
,
res
)
=>
{
res
.
send
(
"
API is Running Successfully
"
);
res
.
send
(
"
API is Running Successfully
"
);
});
});
...
@@ -20,6 +28,8 @@ app.get("/api/chat/:id", (req, res) => {
...
@@ -20,6 +28,8 @@ app.get("/api/chat/:id", (req, res) => {
res
.
send
(
singleChat
);
res
.
send
(
singleChat
);
});
});
const
PORT
=
process
.
env
.
PORT
||
5000
;
const
PORT
=
process
.
env
.
PORT
||
5000
;
app
.
listen
(
5000
,
console
.
log
(
`Server Started on PORT
${
PORT
}
`
));
app
.
listen
(
5000
,
console
.
log
(
`Server Started on PORT
${
PORT
}
`
.
yellow
.
bold
));
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment