Skip to content

Commit 49dec68

Browse files
committed
Initial Commit
1 parent b2f922e commit 49dec68

File tree

5 files changed

+1947
-0
lines changed

5 files changed

+1947
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules

db.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const mongoose=require("mongoose");
2+
require("dotenv").config();
3+
4+
const connection=mongoose.connect(process.env.mongoURL);
5+
6+
module.exports={
7+
connection
8+
}

index.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const express=require("express");
2+
const { connection } = require("./db");
3+
const cors=require("cors")
4+
require("dotenv").config();
5+
6+
const app=express();
7+
8+
app.use(cors());
9+
app.use(express.json());
10+
11+
app.listen(process.env.PORT,async()=>{
12+
try{
13+
await connection;
14+
console.log(`Server is running on ${process.env.PORT} and db is connected`)
15+
}catch(err){
16+
console.log(err)
17+
}
18+
})

0 commit comments

Comments
 (0)