File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ import { user as endpoint } from '../../Endpoints/mod.ts'
3+ import { query } from '../../Fetch.js'
4+
5+
6+ const { log } = console ;
7+
8+
9+ export default async function ( userId , options ) {
10+
11+ const { content = 'all' } = options ;
12+
13+
14+ const { profile } = await
15+ fetch ( userId , content ) ;
16+
17+
18+ if ( content === 'all' ) {
19+
20+ const response = await
21+ fetch ( userId , 'collabs' ) ;
22+
23+ profile . content . content . collabs
24+ = response . profile . content . content . collabs ?? [ ] ;
25+ }
26+
27+ return profile ;
28+ }
29+
30+
31+ async function fetch ( userId , content ) {
32+ return await query ( {
33+ url : endpoint . user ( userId ) ,
34+ parameters : { content }
35+ } ) ;
36+ }
Original file line number Diff line number Diff line change 1+
2+ import { user as endpoint } from '../../Endpoints/mod.ts'
3+ import { query } from '../../Fetch.js'
4+
5+
6+ const { log } = console ;
7+
8+
9+ export default async function ( username ) {
10+
11+ const response = await query ( {
12+ url : endpoint . id ,
13+ parameters : { username }
14+ } ) ;
15+
16+ const { user_id } = response ;
17+
18+ return user_id ;
19+ }
Original file line number Diff line number Diff line change 1+
2+ import { UserContentQuery } from '../../Types/UserContentQuery.ts'
3+ import { Profile } from '../../Types/Profile.ts'
4+
5+ import fetchContent from './Content.js'
6+ import fetchId from './Id.js'
7+
8+
9+
10+ /**
11+ * Resolves the users id from their username.
12+ */
13+
14+ export async function id (
15+
16+ username : string
17+
18+ ) : number {
19+
20+ return await
21+ fetchId ( username ) ;
22+ }
23+
24+
25+ /**
26+ * Queries for a users profile and the content specified.
27+ */
28+
29+ export async function content (
30+
31+ query : UserContentQuery
32+
33+ ) : Profile {
34+
35+ return await
36+ fetchContent ( query ) as Profile ;
37+ }
Original file line number Diff line number Diff line change 11
22
33export const domain
4- = 'https://devrant.com/api/devrant' ;
4+ = 'https://devrant.com/api' ;
5+
6+ export const images
7+ = 'https://avatars.devrant.com' ;
58
69export const rants
7- = `${ domain } /rants` ;
10+ = `${ domain } /devrant/ rants` ;
811
912export const random
1013 = `${ rants } /surprise` ;
Original file line number Diff line number Diff line change 11
2- import { users } from './Base.js'
2+ import { domain , users } from './Base.js'
33
44
5+ export const id =
6+ `${ domain } /get-user-id` ;
7+
58export const user = ( id ) =>
69 `${ users } /${ id } ` ;
710
8- export const edit
9- = `${ users } /me/edit-profile` ;
11+ export const edit =
12+ `${ users } /me/edit-profile` ;
1013
11- export const authenticate
12- = `${ users } /auth-token` ;
14+ export const authenticate =
15+ `${ users } /auth-token` ;
1316
14- export const notifications
15- = `${ users } /me/notif-feed` ;
17+ export const notifications =
18+ `${ users } /me/notif-feed` ;
1619
17- export const avatar
18- = `${ users } /me/avatar` ;
20+ export const avatar =
21+ `${ users } /me/avatar` ;
1922
2023export const subscribe = ( id ) =>
2124 `${ user ( id ) } /subscribe` ;
File renamed without changes.
Original file line number Diff line number Diff line change 1+
2+ const { error , log } = console ;
3+
4+
5+ export async function query ( options ) {
6+
7+ let { url , parameters } = options ;
8+
9+ url = new URL ( url ) ;
10+
11+ parameters ??= { } ;
12+ parameters . app = 3 ;
13+
14+
15+ const { searchParams } = url ;
16+
17+ for ( const [ parameter , value ] of Object . entries ( parameters ) )
18+ searchParams . set ( parameter , value ) ;
19+
20+ log ( url . href ) ;
21+
22+ const response = await fetch ( url ) ;
23+
24+ log ( response ) ;
25+
26+ if ( response . ok )
27+ return await response . json ( ) ;
28+
29+ throw new Error (
30+ `\n${ response . status } : ${ response . statusText } ` +
31+ `\nUrl : ${ response . url } `
32+ )
33+ }
Original file line number Diff line number Diff line change 1+
2+ import { Image } from './Image.ts'
3+ import { Post } from './Post.ts'
4+
5+
6+ export interface Collaboration extends Post {
7+
8+ attached_image : '' | Image ,
9+
10+ user_avatar_lg : Avatar ,
11+
12+ num_comments : number ,
13+
14+ c_type_long : string ,
15+
16+ user_dpp : number ,
17+
18+ c_type : number ,
19+
20+ tags : string [ ] ,
21+
22+ text : string ,
23+
24+ rt : number ,
25+
26+ rc : number ,
27+
28+ id : number ,
29+
30+ }
Original file line number Diff line number Diff line change 22import { Post } from './Post.ts'
33
44
5- export interface Rant extends Post {
5+ export interface Comment extends Post {
66
77 body : string
88
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Avatar } from './Avatar.ts'
33import { Link } from './Link.ts'
44
55
6- export interface Rant {
6+ export interface Post {
77
88 created_time : number ,
99
@@ -15,8 +15,6 @@ export interface Rant {
1515
1616 user_id : number ,
1717
18- edited : bool ,
19-
2018 links ? : Link [ ] ,
2119
2220 score : number
You can’t perform that action at this time.
0 commit comments