1 |
const express = require('express'); |
2 |
const fs = require('fs'); |
3 |
const path = require('path'); |
4 |
|
5 |
const app = express(); |
6 |
|
7 |
app.use(express.json()); |
8 |
app.use(express.urlencoded({ |
9 |
extended: true |
10 |
})); |
11 |
|
12 |
app.get('/', (req, res) => res.send('Bot is running...')); |
13 |
|
14 |
if (fs.existsSync(path.join(__dirname, '..', 'routes', 'api.js'))) { |
15 |
const router = require('../routes/api'); |
16 |
app.use('/api', router); |
17 |
} |
18 |
|
19 |
module.exports = () => app.listen(4000, () => { |
20 |
console.log("Server listening at port 4000"); |
21 |
}); |