-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
32 lines (25 loc) · 799 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
26
27
28
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const dotenv = require('dotenv')
const cors = require('cors')
dotenv.config()
const app = express();
const PORT = 3001;
const mongoURI = process.env.MONGO_URL
mongoose.connect(mongoURI);
const connection = mongoose.connection;
connection.once('open', () => {
console.log('MongoDB database connection established successfully');
});
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cors())
app.use(bodyParser.json());
const orgRoutes = require('./routes/org.router');
app.use('/api', orgRoutes);
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.listen(PORT, async () => {
console.log(`Server is running on http://localhost:${PORT}`);
});