-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (18 loc) · 745 Bytes
/
app.js
File metadata and controls
28 lines (18 loc) · 745 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
27
28
const express = require('express');
const dotenv = require('dotenv');
const paymentRouter = require('./routes/paymentRoute');
const bodyParser = require('body-parser');
const { default: mongoose } = require('mongoose');
const app = express();
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
dotenv.config({path: './config.env'});
const mongoUrl = process.env.DATABASE;
mongoose.connect(mongoUrl).then((con)=>console.log('Database connected successfully'))
app.use(express.json())
app.get('/test', (req, res) => {
res.send('Test route is working');
});
app.use('/api/payment', paymentRouter)
const port = process.env.PORT || 5000
app.listen(port , ()=> console.log(`server listening on port ${port}`))