forked from edupoli/baileys-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (23 loc) · 792 Bytes
/
app.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
29
const app = require('express')(),
http = require('http').Server(app),
io = require('socket.io')(http),
bodyParser = require('body-parser'),
{ response } = require('./response'),
whatsapp = require('./whatsapp'),
{ listen } = require('./socket'),
chats = require('./routes/chatsRouter'),
groups = require('./routes/groupsRouter')
sessions = require('./routes/sessionRouter')
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.use('/chats', chats)
app.use('/groups', groups)
app.use('/sessions', sessions)
app.all('*', (req, res) => {
response(res, 404, {success: false, message: 'The requested url cannot be found.'})
})
whatsapp.init()
http.listen(8000, () => {
listen(io, whatsapp)
console.log('Server listening on http://localhost:8000/')
})