mirror of
https://github.com/hknsh/project-knedita.git
synced 2024-11-28 17:41:15 +00:00
26 lines
635 B
TypeScript
26 lines
635 B
TypeScript
import app from './app'
|
|
import { createServer } from 'http'
|
|
import logger from 'helpers/logger'
|
|
import createSocketIOInstance from './socket'
|
|
|
|
import prisma from 'clients/prisma-client'
|
|
import redis from 'clients/redis-client'
|
|
|
|
const server = createServer(app)
|
|
const io = createSocketIOInstance(server)
|
|
|
|
app.use((req, res, next) => {
|
|
res.locals.io = io
|
|
next()
|
|
})
|
|
|
|
server.listen(process.env.SERVER_PORT, () => {
|
|
logger.info(`Server is running @ ${process.env.SERVER_PORT ?? ''}`)
|
|
})
|
|
|
|
process.on('SIGINT', async () => {
|
|
logger.warn('Closing server...')
|
|
await prisma.$disconnect()
|
|
await redis.disconnect()
|
|
server.close()
|
|
})
|