-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathindex.ts
More file actions
50 lines (48 loc) · 1.54 KB
/
index.ts
File metadata and controls
50 lines (48 loc) · 1.54 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
import {
getUserProfileBio,
getUserProfileBirthday,
getUserProfileBookmarks,
getUserProfileCollections,
getUserProfileGifts,
getUserProfileHeader,
getUserProfileId,
getUserProfileJoined,
getUserProfileLocation,
getUserProfileName,
getUserProfilePic,
getUserProfilePseuds,
getUserProfileSeries,
getUserProfileWorks,
} from "./getters";
import type { User } from "types/entities";
import { getAsShortUrl, getUserProfileUrl } from "src/urls";
import { loadUserProfilePage } from "src/page-loaders";
export const getUser = async ({
username,
}: {
username: string;
}): Promise<User> => {
const profilePage = await loadUserProfilePage({ username });
const url = getUserProfileUrl({ username });
const shortUrl = getAsShortUrl({ url });
return {
// We use this because capitalization might be different
username: getUserProfileName(profilePage),
// TODO: this should really be an array
pseuds: getUserProfilePseuds(profilePage),
id: getUserProfileId(profilePage),
joined: getUserProfileJoined(profilePage),
icon: getUserProfilePic(profilePage),
header: getUserProfileHeader(profilePage),
location: getUserProfileLocation(profilePage),
birthday: getUserProfileBirthday(profilePage),
url,
shortUrl,
works: getUserProfileWorks(profilePage),
series: getUserProfileSeries(profilePage),
bookmarks: getUserProfileBookmarks(profilePage),
collections: getUserProfileCollections(profilePage),
gifts: getUserProfileGifts(profilePage),
bioHtml: getUserProfileBio(profilePage),
};
};