-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathservice.ts
More file actions
57 lines (52 loc) · 1.48 KB
/
service.ts
File metadata and controls
57 lines (52 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as queries from "./queries";
import { MediaSettingsResponse } from "./schemas";
import {
thumbnailHeight as defaultThumbnailHeight,
thumbnailWidth as defaultThumbnailWidth,
} from "../config/constants";
export async function getMediaSettings(
userId: string,
apikey: string,
): Promise<MediaSettingsResponse> {
const mediaSettings = await queries.getMediaSettings(userId, apikey);
if (!mediaSettings) {
return {
useWebP: false,
webpOutputQuality: 0,
thumbnailHeight: defaultThumbnailHeight,
thumbnailWidth: defaultThumbnailWidth,
};
}
return {
useWebP: mediaSettings.useWebP || false,
webpOutputQuality: mediaSettings.webpOutputQuality || 0,
thumbnailHeight:
mediaSettings.thumbnailHeight || defaultThumbnailHeight,
thumbnailWidth: mediaSettings.thumbnailWidth || defaultThumbnailWidth,
};
}
export interface UpdateMediaSettingsProps {
userId: string;
apikey: string;
useWebP: boolean;
webpOutputQuality: number;
thumbnailWidth: number;
thumbnailHeight: number;
}
export async function updateMediaSettings({
userId,
apikey,
useWebP,
webpOutputQuality,
thumbnailWidth,
thumbnailHeight,
}: UpdateMediaSettingsProps): Promise<void> {
await queries.updateMediaSettings({
userId,
apikey,
useWebP,
webpOutputQuality,
thumbnailWidth,
thumbnailHeight,
});
}