api requests work, added simple tests... TODO: URL Object needs to be cloned for memory safety

This commit is contained in:
fzzin
2025-04-10 11:37:18 +02:00
parent aa834bda66
commit ab6ec7fc3d
3 changed files with 27 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
import { requestJSON } from "@root/structures/apiRequest.ts";
import { handlePostRequest } from "@root/plugins/yandere/api/post.ts";
const baseURL = "https://yande.re";
const apikeys = [
@@ -52,6 +52,17 @@ function prepareURLObjectForRequest(type: APIKeys) {
export function getPosts(search? : string){
const url = prepareURLObjectForRequest("post")
return requestJSON(url)
return handlePostRequest(url, search)
}
Deno.test("Empty Post Request", async() => {
console.debug(await getPosts())
})
Deno.test("Post Request with tag", async() => {
console.debug(await getPosts("[tags:love_live!_(series)]"))
})
Deno.test("Post Request with limit", async() => {
console.debug(await getPosts("[limit: 1)]"))
})