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/models/Message.ts

35 lines
719 B
TypeScript

import type { Message } from '@prisma/client'
import { Type } from '@sinclair/typebox'
import { date, id } from './utils.js'
export const types = [Type.Literal('text'), Type.Literal('file')]
export const messageSchema = {
id,
value: Type.String({
minLength: 1,
maxLength: 20_000
}),
type: Type.Union(types, { default: 'text' }),
mimetype: Type.String({
maxLength: 127,
default: 'text/plain'
}),
createdAt: date.createdAt,
updatedAt: date.updatedAt,
memberId: id,
channelId: id
}
export const messageExample: Message = {
id: 1,
value: 'Hello, world!',
type: 'text',
mimetype: 'text/plain',
createdAt: new Date(),
updatedAt: new Date(),
memberId: 1,
channelId: 1
}