Compare commits

...

2 Commits

Author SHA1 Message Date
Suguivy cdb44655b7 Merge pull request 'Added parameters as env vars' (#5) from feature/envvars-parametrization into main
Unit Tests with docker compose / unit-test (push) Successful in 21s Details
Build image / build (push) Failing after 22s Details
Reviewed-on: #5

Solves issue #3
2024-04-17 17:51:58 +00:00
Sugui 050eb48aa2 Added parameters as env vars
Unit Tests with docker compose / unit-test (push) Successful in 22s Details
Unit Tests with docker compose / unit-test (pull_request) Successful in 21s Details
2024-04-17 19:48:56 +02:00
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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<GelbooruServiceResponse> {
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 => {