Upload index.ts
Browse files- src/index.ts +26 -0
src/index.ts
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Fastify from 'fastify'
|
2 |
+
import { Server } from 'socket.io'
|
3 |
+
import { PrismaClient } from '@prisma/client'
|
4 |
+
|
5 |
+
const fastify = Fastify({ logger: true })
|
6 |
+
const io = new Server(fastify.server)
|
7 |
+
const prisma = new PrismaClient()
|
8 |
+
|
9 |
+
fastify.get('/', async () => {
|
10 |
+
return { status: 'ok' }
|
11 |
+
})
|
12 |
+
|
13 |
+
io.on('connection', (socket) => {
|
14 |
+
console.log('Client connected')
|
15 |
+
})
|
16 |
+
|
17 |
+
const start = async () => {
|
18 |
+
try {
|
19 |
+
await fastify.listen({ port: 7860, host: '0.0.0.0' })
|
20 |
+
} catch (err) {
|
21 |
+
fastify.log.error(err)
|
22 |
+
process.exit(1)
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
start()
|