forked from mtegarsantosa/ngantri
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
36 lines (32 loc) · 1020 Bytes
/
main.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
30
31
32
33
34
35
36
const express = require('express')
const app = express()
const path = require('path')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const http = require('http').Server(app)
const io = require('socket.io')(http)
const db = require('./conn')
const view_format = 'hbs'
app.use(bodyParser.json())
app.use(cookieParser())
io.on('connection',(socket)=>{
console.log('socket connected')
app.post('/voice', (req,res)=>{
io.sockets.emit('voice',req.body.voice)
})
})
// handlebars
const exphbs = require('express-handlebars')
app.engine(view_format, exphbs({
extname:view_format,
partialsDir: path.join(__dirname,'app','views','partials')
}))
app.set('view engine', view_format)
app.set('views', path.join(__dirname,'app','views'))
// route
app.use('/assets',express.static(path.join(__dirname,'public')))
app.use('/', require(__dirname+'/route'))
// server
http.listen(3000, ()=>{
console.log('server njalan di lobang 3000..')
})