-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (22 loc) · 767 Bytes
/
server.js
File metadata and controls
27 lines (22 loc) · 767 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
import express from 'express'
import http from 'http'
import next from 'next'
import api from 'server/api'
import intializeSocket from 'server/socket'
import { emitProjects } from 'server/socket/emitProjects'
import { poll } from 'common/utilities/polling'
import { syncProjects } from 'server/data/syncProjects'
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const nextApp = next({ dev })
const expressApp = express()
const server = http.Server(expressApp)
nextApp.prepare().then(() => {
const socket = intializeSocket(server)
api(expressApp, nextApp)
server.listen(port, () => {
console.log('Server listening at port %d', port)
})
syncProjects()
poll(() => emitProjects(socket), 10000)
})