This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
api/src/index.ts

23 lines
588 B
TypeScript
Raw Normal View History

2021-10-24 04:06:16 +02:00
import { authorize } from '@thream/socketio-jwt'
import application from './application'
import { socket } from './tools/socket'
import { sequelize } from './tools/database/sequelize'
const PORT = parseInt(process.env.PORT ?? '8080', 10)
sequelize
.sync()
.then(() => {
const server = application.listen(PORT, () => {
console.log('\x1b[36m%s\x1b[0m', `🚀 Server listening on port ${PORT}.`)
})
socket.init(server)
socket.io?.use(
authorize({
secret: process.env.JWT_ACCESS_SECRET
})
)
})
.catch((error) => console.error(error))