-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (17 loc) 路 773 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (17 loc) 路 773 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
25
26
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const noticeRoutes = require('./routes/noticeRoutes');
const adminRoutes = require('./routes/adminRoutes');
const app = express();
app.use(cors());
app.use(express.json());
mongoose.connect('mongodb+srv://Sharmarjun25:sharmarjun25@cluster0.qwm4ugs.mongodb.net/communityboard?retryWrites=true&w=majority')
.then(() => console.log('Connected to MongoDB successfully!'))
.catch(err => console.error('MongoDB connection error:', err));
app.use('/api/notices', noticeRoutes);
app.use('/api/admin', adminRoutes);
const PORT = 3000;
app.listen(PORT, () => {
console.log(`馃殌 Server is running on http://localhost:${PORT}`);
});