-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (20 loc) · 916 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
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const home = require('./Routes/home');
const search = require('./Routes/search');
const product = require('./Routes/product');
const clientProfile = require('./Routes/clientProfile');
const PORT = process.env.PORT || 5000;
const app = express();
app.use(cors());
app.use(express.urlencoded({ extended: true }));
const MONGOURI = process.env.MONGO_URI || "mongodb+srv://Adim-Dev:[email protected]/Grabble?retryWrites=true&w=majority"
mongoose
.connect(MONGOURI, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true })
.then(() => console.log('Connected to Mongo'));
app.use('', home);
app.use('/search', search);
app.use('/product', product);
app.use('/client-profile', clientProfile);
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));