-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 784 Bytes
/
Copy pathserver.js
File metadata and controls
24 lines (19 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const authRoutes = require('./routes/auth');
const verifyToken = require('./middleware/authMiddleware');
dotenv.config();
const app = express();
const PORT = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use(express.static('public'));
app.use('/uploads', express.static('uploads'));
mongoose.connect(process.env.MONGODB_URI, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('MongoDB connected'))
.catch(err => console.log('MongoDB connection error:', err));
app.use('/api', authRoutes);
app.listen(PORT, () => {
console.log(`Server running on https://localhost:${PORT}`);
});