Skip to content

Commit d9a03d8

Browse files
committed
chore: wire browse/sell pages, make DB optional, fix dev scripts, remove commitlint hook
1 parent 4168b6d commit d9a03d8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Backend for UniLoot - college-exclusive e-commerce platform",
55
"main": "server.ts",
66
"scripts": {
7-
"dev": "ts-node-dev --respawn --transpile-only server.ts",
7+
"dev": "ts-node-dev --respawn --transpile-only src/server.ts",
88
"build": "tsc",
99
"start": "nodemon dist/server.js"
1010
},

backend/src/app.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ app.get("/", (_req, res) => {
2323
res.send("API is running 🚀");
2424
});
2525

26-
// MongoDB connect (example)
27-
mongoose
28-
.connect(process.env.MONGO_URI || "")
29-
.then(() => console.log("MongoDB connected"))
30-
.catch((err) => console.error("MongoDB connection error:", err));
26+
// MongoDB connect (optional)
27+
const mongoUri = process.env.MONGO_URI;
28+
if (mongoUri && (mongoUri.startsWith("mongodb://") || mongoUri.startsWith("mongodb+srv://"))) {
29+
mongoose
30+
.connect(mongoUri)
31+
.then(() => console.log("MongoDB connected"))
32+
.catch((err) => console.error("MongoDB connection error:", err));
33+
} else {
34+
console.warn("MONGO_URI not set or invalid. Skipping MongoDB connection. Set MONGO_URI in .env to enable DB.");
35+
}
3136

3237
export default app;

0 commit comments

Comments
 (0)