работаем бля работаем

This commit is contained in:
2026-05-09 03:21:44 +06:00
parent f845777bac
commit 0b148c6a7d
169 changed files with 15816 additions and 1005 deletions

View File

@@ -1,7 +1,7 @@
import type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox'
import { Type } from 'typebox'
import { UserSchema } from '../schemas/auth.ts'
import { UpdateUserPreferencesSchema, UserPreferencesSchema } from '../schemas/user.ts'
import { UserSchema } from '../plugins/schemas/auth.ts'
import { GetUserQuerySchema, UpdateUserPayloadSchema, UpdateUserPreferencesPayloadSchema, UserPreferencesSchema } from '../plugins/schemas/user.ts'
import { TypeboxRef } from '../utils/typebox-ref.ts'
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
fastify.get(
@@ -11,11 +11,9 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
summary: 'Get user',
tags: ['User'],
operationId: 'user.get',
querystring: Type.Partial(Type.Object({
username: Type.String(),
})),
querystring: TypeboxRef(GetUserQuerySchema),
response: {
200: UserSchema,
200: TypeboxRef(UserSchema),
},
},
},
@@ -49,11 +47,11 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
tags: ['User'],
operationId: 'user.getPreferences',
response: {
200: UserPreferencesSchema,
200: TypeboxRef(UserPreferencesSchema),
},
},
},
async (req, reply) => {
async (req) => {
const user = req.user!
const preferences = await fastify.prisma.userPreferences.upsert({
@@ -62,10 +60,6 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
update: {},
})
if (!preferences) {
return reply.notFound('User preferences not found')
}
return {
toggleInputHotkey: preferences.toggleInputHotkey || '',
toggleOutputHotkey: preferences.toggleOutputHotkey || '',
@@ -80,7 +74,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
summary: 'Update preferences',
tags: ['User'],
operationId: 'user.updatePreferences',
body: UpdateUserPreferencesSchema,
body: TypeboxRef(UpdateUserPreferencesPayloadSchema),
},
},
async (req) => {
@@ -104,11 +98,9 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
summary: 'Update profile',
tags: ['User'],
operationId: 'user.updateProfile',
body: Type.Object({
displayName: Type.String(),
}),
body: TypeboxRef(UpdateUserPayloadSchema),
response: {
200: UserSchema,
200: TypeboxRef(UserSchema),
},
},
},