24 lines
583 B
TypeScript
24 lines
583 B
TypeScript
import type { FastifyInstance } from 'fastify'
|
|
import prisma from '../prisma/client.ts'
|
|
|
|
export default function (fastify: FastifyInstance) {
|
|
fastify.get('/chats', async (req, reply) => {
|
|
if (req.user) {
|
|
return prisma.chatChannel.findMany()
|
|
}
|
|
|
|
reply.code(401).send(false)
|
|
})
|
|
|
|
fastify.get('/chats/:id', async (req, reply) => {
|
|
if (req.user) {
|
|
console.log('Trying to fetch chat with id', req.body.id)
|
|
|
|
// return prisma.userPreferences.findFirst({ where: { userId: req.user.id } })
|
|
return true
|
|
}
|
|
|
|
reply.code(401).send(false)
|
|
})
|
|
}
|