-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
25 lines (19 loc) · 972 Bytes
/
index.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
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import userRoutes from './routes/user-routes.js';
import authRoutes from './routes/auth-routes.js';
const app = express();
app.use(bodyParser.json({ limit : "20mb", extended: true }))
app.use(bodyParser.urlencoded({ limit: "20mb", extended: true }))
app.use(cors());
app.use('/api/auth', authRoutes);
app.use('/api/users', userRoutes);
//store connection in Env variables before deploying
const CONNECTION_URL = "mongodb+srv://mansukhp96:[email protected]/myFirstDatabase?retryWrites=true&w=majority";
const PORT = process.env.PORT || 5000;
mongoose.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`) ))
.catch((error) => console.log(error.message));
mongoose.set('useFindAndModify', false);