-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
79 lines (46 loc) · 1.65 KB
/
index.js
File metadata and controls
79 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require("dotenv").config();
const express = require('express');
const mongoose = require('mongoose');
const cors = require("cors");
const blogRoutes = require('./src/routes/blog.route');
const carRoutes = require('./src/routes/car.route');
const userRoutes = require('./src/routes/user.route');
const productRoutes = require('./src/routes/product.route');
const adminRoutes = require('./src/routes/admin.route');
const app = express();
app.use(cors());
app.use(express.json());
// app.use('/api/v1/', productRoutes);
app.use('/api/v1/blogs', blogRoutes);
app.use('/api/v1/cars', carRoutes);
app.use('/api/v1/auth', userRoutes)
app.use('/api/v1/products', productRoutes)
app.use('/api/v1/admin', adminRoutes)
app.get('/', (req, res) => {
res.send('Welcome to the Product API');
});
//not found page
app.use((req, res) => {
res.status(404).send("Page Not Found");
})
const port = 3000;
//commit
const start = async() => {
try {
const conn = await mongoose.connect(process.env.MONGO_URL);
console.log("Connected to MongoDB");
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
} catch (error) {
console.error("Error connecting to MongoDB:", error);
};
};
start();
// mongodb+srv://sqi:[email protected]/?appName=Cluster0
//username xfigures6_db_user
//password DLuKUbKjlJiaGbev
// mongodb+srv://<db_username>:<db_password>@cluster0.ziwtgfi.mongodb.net/?appName=Cluster0
// mongodb+srv://xfigures6_db_user:[email protected]/jan-learn
// busayo
// mongodb+srv://busayoadebayo280_db_user:<db_password>@cluster0.usrxdnr.mongodb.net/?appName=Cluster0