-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef6ec28
commit ff2c125
Showing
14 changed files
with
198 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import { user as endpoint } from '../../Endpoints/mod.ts' | ||
import { query } from '../../Fetch.js' | ||
|
||
|
||
const { log } = console; | ||
|
||
|
||
export default async function ( userId , options ){ | ||
|
||
const { content = 'all' } = options; | ||
|
||
|
||
const { profile } = await | ||
fetch(userId,content); | ||
|
||
|
||
if(content === 'all'){ | ||
|
||
const response = await | ||
fetch(userId,'collabs'); | ||
|
||
profile.content.content.collabs | ||
= response.profile.content.content.collabs ?? []; | ||
} | ||
|
||
return profile; | ||
} | ||
|
||
|
||
async function fetch ( userId , content ){ | ||
return await query({ | ||
url : endpoint.user( userId ) , | ||
parameters : { content } | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
import { user as endpoint } from '../../Endpoints/mod.ts' | ||
import { query } from '../../Fetch.js' | ||
|
||
|
||
const { log } = console; | ||
|
||
|
||
export default async function ( username ){ | ||
|
||
const response = await query({ | ||
url : endpoint.id , | ||
parameters : { username } | ||
}); | ||
|
||
const { user_id } = response; | ||
|
||
return user_id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
import { UserContentQuery } from '../../Types/UserContentQuery.ts' | ||
import { Profile } from '../../Types/Profile.ts' | ||
|
||
import fetchContent from './Content.js' | ||
import fetchId from './Id.js' | ||
|
||
|
||
|
||
/** | ||
* Resolves the users id from their username. | ||
*/ | ||
|
||
export async function id ( | ||
|
||
username : string | ||
|
||
) : number { | ||
|
||
return await | ||
fetchId ( username ); | ||
} | ||
|
||
|
||
/** | ||
* Queries for a users profile and the content specified. | ||
*/ | ||
|
||
export async function content ( | ||
|
||
query : UserContentQuery | ||
|
||
) : Profile { | ||
|
||
return await | ||
fetchContent ( query ) as Profile; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
const { error , log } = console; | ||
|
||
|
||
export async function query ( options ){ | ||
|
||
let { url , parameters } = options; | ||
|
||
url = new URL(url); | ||
|
||
parameters ??= {}; | ||
parameters.app = 3; | ||
|
||
|
||
const { searchParams } = url; | ||
|
||
for(const [ parameter , value ] of Object.entries(parameters)) | ||
searchParams.set(parameter,value); | ||
|
||
log(url.href); | ||
|
||
const response = await fetch(url); | ||
|
||
log(response); | ||
|
||
if(response.ok) | ||
return await response.json(); | ||
|
||
throw new Error( | ||
`\n${ response.status } : ${ response.statusText }` + | ||
`\nUrl : ${ response.url }` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import { Image } from './Image.ts' | ||
import { Post } from './Post.ts' | ||
|
||
|
||
export interface Collaboration extends Post { | ||
|
||
attached_image : '' | Image , | ||
|
||
user_avatar_lg : Avatar , | ||
|
||
num_comments : number , | ||
|
||
c_type_long : string , | ||
|
||
user_dpp : number , | ||
|
||
c_type : number , | ||
|
||
tags : string [] , | ||
|
||
text : string , | ||
|
||
rt : number , | ||
|
||
rc : number , | ||
|
||
id : number , | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
import { UserContentType } from './UserContentType.ts' | ||
|
||
|
||
export interface UserContentQuery { | ||
|
||
content : UserContentType , | ||
|
||
userId : string | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
|
||
export enum UserContentType { | ||
|
||
Collaborations , | ||
Collaborations = 'collabs' , | ||
|
||
Everything , | ||
Everything = 'all' , | ||
|
||
Favorites , | ||
Favorites = 'favorites' , | ||
|
||
Comments , | ||
Comments = 'comments' , | ||
|
||
Rants , | ||
Rants = 'rants' , | ||
|
||
Likes | ||
Likes = 'likes' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
export * as User from './API/User/mod.ts' |