diff --git a/compose.yml b/compose.yml index 74d98bb..5e72207 100644 --- a/compose.yml +++ b/compose.yml @@ -38,6 +38,8 @@ services: environment: PORT: 8081 BOT_API_URI: "http://bot-api:8080" + GELBOORU_IMAGES_PER_REQUEST: 100 # Number of images per request, maximum 100 + GELBOORU_TAGS: "2girls sleeping" # Tags of the images. The images will have all of these tags volumes: - ./:/usr/src/app:ro diff --git a/src/services/GelbooruApiService.ts b/src/services/GelbooruApiService.ts index 3a4d5dc..8a38f27 100644 --- a/src/services/GelbooruApiService.ts +++ b/src/services/GelbooruApiService.ts @@ -1,10 +1,12 @@ +import { env } from "bun"; import GelbooruApiResponse from "src/types/GelbooruApiResponse"; import GelbooruServiceResponse from "src/types/GelbooruServiceResponse"; class GelbooruApiService { async get(): Promise { - const limit = 100; - const url: string = `https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=${limit}&json=1&tags=2girls+sleeping` + const LIMIT = env.GELBOORU_IMAGES_PER_REQUEST || 100; + const TAGS = encodeURIComponent(env.GELBOORU_TAGS || ""); + const url: string = `https://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=${LIMIT}&json=1&tags=${TAGS}`; const response: GelbooruApiResponse = await fetch(url) .then(res => {