Skip to content

Commit 04502bc

Browse files
committed
inserting user code into a collection
1 parent 63a6938 commit 04502bc

6 files changed

Lines changed: 290 additions & 72 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.dropIntoEditor.preferences": []
3+
}

remote-machine/db.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import mongoose from "mongoose";
2-
2+
import dotenv from "dotenv";
3+
dotenv.config();
34
const MONGO_URI = process.env.MONGO_URI;
45

56
async function connectDB() {
67
try {
7-
await mongoose.connect(MONGO_URI);
8+
await mongoose.connect('mongodb://vign2020_db_user:QPFKztmAvjGqBG00D@ac-nwvq1cp-shard-00-00.veuwryl.mongodb.net:27017,ac-nwvq1cp-shard-00-01.veuwryl.mongodb.net:27017,ac-nwvq1cp-shard-00-02.veuwryl.mongodb.net:27017/CodeCrunch?ssl=true&replicaSet=atlas-vlw7hl-shard-0&authSource=admin&appName=CodeCrunch-1');
89
console.log("MongoDB connected");
910
} catch (err) {
1011
console.error("DB connection error:", err);
1112
process.exit(1);
1213
}
1314
}
1415

15-
export default connectDB;
16+
export default connectDB;

remote-machine/server.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1+
/** @format */
2+
13
import express from "express";
24
import bodyParser from "body-parser";
35

4-
56
import dotenv from "dotenv";
6-
import dbConnect from "./db.js";
7+
import connectDB from "./db.js";
78

89
dotenv.config();
910
const PORT = process.env.PORT || 8000;
1011

1112
const app = express();
1213
app.use(bodyParser.json());
1314

14-
15-
await dbConnect();
16-
17-
app.get("/health",(req, res)=>{
18-
try{
19-
res.status(200).json({message : "all working fine !!"});
20-
}
21-
catch(e){
22-
res.status(500).json({message : "Not reachable !!"});
23-
}
15+
app.get("/health", (req, res) => {
16+
try {
17+
res.status(200).json({ message: "all working fine !!" });
18+
} catch (e) {
19+
res.status(500).json({ message: "Not reachable !!" });
20+
}
2421
});
2522

26-
app.listen(PORT, "0.0.0.0", () => {
27-
console.log(`Server running on port ${PORT}`);
28-
});
23+
const startServer = (async () => {
24+
await connectDB();
25+
app.listen(PORT, "0.0.0.0", () => {
26+
console.log(`Server running on port ${PORT}`);
27+
});
28+
})();

remote-machine/worker/package-lock.json

Lines changed: 212 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remote-machine/worker/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
8-
98
},
109
"type": "module",
1110
"keywords": [],
1211
"author": "",
1312
"license": "ISC",
1413
"dependencies": {
1514
"@aws-sdk/client-sqs": "^3.985.0",
16-
"dotenv": "^17.3.1"
15+
"dotenv": "^17.3.1",
16+
"mongoose": "^9.3.3"
1717
}
1818
}

0 commit comments

Comments
 (0)