mirror of
https://github.com/p-stream/backend.git
synced 2026-01-11 20:10:33 +00:00
changed interfaces to more reusable/safe imports from prisma
This commit is contained in:
parent
9e70182f6e
commit
b956aa7297
3 changed files with 8 additions and 56 deletions
|
|
@ -1,14 +1,6 @@
|
|||
import { useAuth } from '~/utils/auth';
|
||||
import { z } from 'zod';
|
||||
|
||||
interface BookmarkWithFavorites {
|
||||
tmdb_id: string;
|
||||
user_id: string;
|
||||
meta: any;
|
||||
group: string[];
|
||||
favorite_episodes: string[];
|
||||
updated_at: Date;
|
||||
}
|
||||
import { bookmarks } from '@prisma/client';
|
||||
|
||||
const bookmarkMetaSchema = z.object({
|
||||
title: z.string(),
|
||||
|
|
@ -42,7 +34,7 @@ export default defineEventHandler(async event => {
|
|||
where: { user_id: userId },
|
||||
});
|
||||
|
||||
return bookmarks.map((bookmark: BookmarkWithFavorites) => ({
|
||||
return bookmarks.map((bookmark: bookmarks) => ({
|
||||
tmdbId: bookmark.tmdb_id,
|
||||
meta: bookmark.meta,
|
||||
group: bookmark.group,
|
||||
|
|
@ -88,7 +80,7 @@ export default defineEventHandler(async event => {
|
|||
favorite_episodes: normalizedFavoriteEpisodes,
|
||||
updated_at: now,
|
||||
} as any,
|
||||
}) as BookmarkWithFavorites;
|
||||
}) as bookmarks;
|
||||
|
||||
results.push({
|
||||
tmdbId: bookmark.tmdb_id,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
import { useAuth } from '~/utils/auth';
|
||||
import { z } from 'zod';
|
||||
import { scopedLogger } from '~/utils/logger';
|
||||
|
||||
interface BookmarkWithFavorites {
|
||||
tmdb_id: string;
|
||||
user_id: string;
|
||||
meta: any;
|
||||
group: string[];
|
||||
favorite_episodes: string[];
|
||||
updated_at: Date;
|
||||
}
|
||||
import { bookmarks } from '@prisma/client';
|
||||
|
||||
const log = scopedLogger('user-bookmarks');
|
||||
|
||||
|
|
@ -87,7 +79,7 @@ export default defineEventHandler(async event => {
|
|||
favorite_episodes: normalizedFavoriteEpisodes,
|
||||
updated_at: new Date(),
|
||||
} as any,
|
||||
}) as BookmarkWithFavorites;
|
||||
}) as bookmarks;
|
||||
|
||||
log.info('Bookmark created successfully', { userId, tmdbId });
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,10 @@
|
|||
import { useAuth } from '~/utils/auth';
|
||||
import { z } from 'zod';
|
||||
import { scopedLogger } from '~/utils/logger';
|
||||
import { user_settings } from '@prisma/client';
|
||||
|
||||
const log = scopedLogger('user-settings');
|
||||
|
||||
interface UserSettings {
|
||||
id: string;
|
||||
application_theme: string | null;
|
||||
application_language: string;
|
||||
default_subtitle_language: string | null;
|
||||
proxy_urls: string[];
|
||||
trakt_key: string | null;
|
||||
febbox_key: string | null;
|
||||
real_debrid_key: string | null;
|
||||
enable_thumbnails: boolean;
|
||||
enable_autoplay: boolean;
|
||||
enable_skip_credits: boolean;
|
||||
enable_discover: boolean;
|
||||
enable_featured: boolean;
|
||||
enable_details_modal: boolean;
|
||||
enable_image_logos: boolean;
|
||||
enable_carousel_view: boolean;
|
||||
force_compact_episode_view: boolean;
|
||||
source_order: string[];
|
||||
enable_source_order: boolean;
|
||||
disabled_sources: string[];
|
||||
embed_order: string[];
|
||||
enable_embed_order: boolean;
|
||||
disabled_embeds: string[];
|
||||
proxy_tmdb: boolean;
|
||||
enable_low_performance_mode: boolean;
|
||||
enable_native_subtitles: boolean;
|
||||
enable_hold_to_boost: boolean;
|
||||
home_section_order: string[];
|
||||
manual_source_selection: boolean;
|
||||
enable_double_click_to_seek: boolean;
|
||||
}
|
||||
|
||||
const userSettingsSchema = z.object({
|
||||
applicationTheme: z.string().nullable().optional(),
|
||||
applicationLanguage: z.string().optional().default('en'),
|
||||
|
|
@ -97,7 +65,7 @@ export default defineEventHandler(async event => {
|
|||
try {
|
||||
const settings = await prisma.user_settings.findUnique({
|
||||
where: { id: userId },
|
||||
}) as unknown as UserSettings | null;
|
||||
}) as unknown as user_settings | null;
|
||||
|
||||
return {
|
||||
id: userId,
|
||||
|
|
@ -191,7 +159,7 @@ export default defineEventHandler(async event => {
|
|||
id: userId,
|
||||
...data,
|
||||
},
|
||||
}) as unknown as UserSettings;
|
||||
}) as unknown as user_settings;
|
||||
|
||||
log.info('Settings updated successfully', { userId });
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue