import { json } from "@sveltejs/kit";
import type { RequestHandler } from "./$types";
import { putObject } from "$lib/helpers/s3";



export const GET: RequestHandler = async ({ params }) => {

  const inputName = params.name;

  const prompt = `upper body realistic portrait oil painting of a masked ${inputName}, Baroque, Charles Vess, masked ball attire, Charles Vess, opulence, mystery, elegance, dark long hair`;
  const negativePrompt = "blurry, multiple persons, picture frame";

  const image = generateImage(prompt, negativePrompt);

  const imageName = `txt2img_${image.seed}.png`;

  const res = await putObject(imageName, Buffer.from(image.base64, 'base64'), { contentType: "image/png" });

  return json({
    ...res,
    url: `https://s3.app.max-richter.dev/silvester23/${imageName}`
  });
};

