-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (24 loc) · 895 Bytes
/
server.js
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
// server.js
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose')
const simpleApiRoute = require('./routes/simpleApiRoute')
const itemsRouter = require("./routes/itemsRoute")
const productRouter = require("./routes/productRoute")
const userRouter = require("./routes/userRoute")
const app = express();
app.use(bodyParser.json());
const MONGO_URI = 'mongodb://127.0.0.1:27017/testdatabase'; // Update as needed
mongoose.connect(MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error('MongoDB connection error:', err));
app.use('/api/simpleApi',simpleApiRoute)
app.use("/api/items",itemsRouter)
app.use("/api/products",productRouter)
app.use("/api/users",userRouter)
var port = 3000;
app.listen(port)
module.exports = app