diff --git a/proxy.js b/proxy.js deleted file mode 100644 index 84ff9d1..0000000 --- a/proxy.js +++ /dev/null @@ -1,42 +0,0 @@ -import http from 'http'; -import httpProxy from 'http-proxy'; -import dotenv from 'dotenv'; - -// Load environment variables from .env file -dotenv.config(); - -const proxy = httpProxy.createProxyServer({}); -const PORT = 5000; - -// Retrieve the Bearer token from the environment variable -const BEARER_TOKEN = process.env.ASTRIA_API_KEY; - -const server = http.createServer((req, res) => { - const target = 'https://api.astria.ai'; - - // Set CORS headers - res.setHeader('Access-Control-Allow-Origin', '*'); // Allow all origins, or specify a domain - res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, DELETE'); // Specify allowed methods - res.setHeader('Access-Control-Allow-Headers', 'Authorization, Content-Type'); // Specify allowed headers - - // Handle preflight requests - if (req.method === 'OPTIONS') { - res.writeHead(204); // No content - console.log('Preflight request received'); - return res.end(); - } - - - // Set the Authorization header for the proxied request - req.headers['Authorization'] = `Bearer ${BEARER_TOKEN}`; - - proxy.web(req, res, { target, changeOrigin: true }, (error) => { - console.error('Proxy error:', error); - res.writeHead(500, { 'Content-Type': 'text/plain' }); - res.end('Proxy error occurred.'); - }); -}); - -server.listen(PORT, () => { - console.log(`Proxy server running at http://localhost:${PORT}`); -}); diff --git a/src/components/PromptCard/PropertiesDisplay.tsx b/src/components/PromptCard/PropertiesDisplay.tsx index cf0d761..901ffb1 100644 --- a/src/components/PromptCard/PropertiesDisplay.tsx +++ b/src/components/PromptCard/PropertiesDisplay.tsx @@ -1,76 +1,115 @@ import React from "react"; import { Prompt } from "@/types"; +import { Paperclip } from "lucide-react"; interface PropertiesDisplayProps { - prompt: Prompt; + prompt: Prompt; } type DisplayProperty = { - key: keyof Prompt | [keyof Prompt, keyof Prompt]; // Single key or tuple for combination - label: string; - extraText?: string; - link?: string; - joiner?: string; + key: keyof Prompt | [keyof Prompt, keyof Prompt]; // Single key or tuple for combination + label: string; + extraText?: string; + link?: string; + joiner?: string; }; const displayProperties: DisplayProperty[] = [ - { key: "style", label: "Style" }, - { key: "cfg_scale", label: "Scale" }, - { key: "seed", label: "Seed" }, - { key: "steps", label: "Steps" }, - { key: ["w", "h"], label: "Size", joiner: "x" }, // Combined w and h with "x" as joiner - { key: "scheduler", label: "Scheduler" }, - { key: "color_grading", label: "Color Grading" }, - { key: "film_grain", label: "Film Grain" }, - { key: "super_resolution", label: "Super-Resolution" }, - { key: "only_upscale", label: "Upscale", link: "https://docs.astria.ai/docs/use-cases/upscale" }, - { key: "tiled_upscale", label: "Tiled Upscale", link: "https://docs.astria.ai/docs/features/tiled-upscale" }, - { key: "hires_fix", label: "HiRes Fix" }, - { key: "face_correct", label: "Face Correct" }, - { key: "face_swap", label: "Face Swap", link: "https://docs.astria.ai/docs/features/face-swap" }, - { key: "inpaint_faces", label: "Inpaint Faces", link: "https://docs.astria.ai/docs/features/face-inpainting" }, - { key: "is_multiperson", label: "Multiperson" }, - { key: "prompt_expansion", label: "Prompt Expansion" }, - { key: "theme", label: "Theme" }, - { key: "input_image", label: "Image" }, - { key: "mask_image", label: "Mask" }, - { key: "controlnet", label: "ControlNet", link: "https://docs.astria.ai/docs/use-cases/controlnet" }, - { key: "use_lpw", label: "Weighted" }, + { key: "style", label: "Style" }, + { key: "cfg_scale", label: "Scale" }, + { key: "seed", label: "Seed" }, + { key: "steps", label: "Steps" }, + { key: ["w", "h"], label: "Size", joiner: "x" }, // Combined w and h with "x" as joiner + { key: "scheduler", label: "Scheduler" }, + { key: "color_grading", label: "Color Grading" }, + { key: "film_grain", label: "Film Grain" }, + { key: "super_resolution", label: "Super-Resolution" }, + { + key: "only_upscale", + label: "Upscale", + link: "https://docs.astria.ai/docs/use-cases/upscale", + }, + { + key: "tiled_upscale", + label: "Tiled Upscale", + link: "https://docs.astria.ai/docs/features/tiled-upscale", + }, + { key: "hires_fix", label: "HiRes Fix" }, + { key: "face_correct", label: "Face Correct" }, + { + key: "face_swap", + label: "Face Swap", + link: "https://docs.astria.ai/docs/features/face-swap", + }, + { + key: "inpaint_faces", + label: "Inpaint Faces", + link: "https://docs.astria.ai/docs/features/face-inpainting", + }, + { key: "is_multiperson", label: "Multiperson" }, + { key: "prompt_expansion", label: "Prompt Expansion" }, + { key: "theme", label: "Theme" }, + { key: "mask_image", label: "Mask" }, + { + key: "controlnet", + label: "ControlNet", + link: "https://docs.astria.ai/docs/use-cases/controlnet", + }, + { key: "use_lpw", label: "Weighted" }, ]; -export const PropertiesDisplay: React.FC = ({ prompt }) => { - console.log("prompt", {prompt}); - return ( -
- {displayProperties.map(({ key, label, extraText, link, joiner }) => { - let displayValue; +export const PropertiesDisplay: React.FC = ({ + prompt, +}) => { + console.log("prompt", { prompt }); + return ( + <> + {prompt.input_image && ( +
+ + +
+ )} +
+ {displayProperties.map(({ key, label, extraText, link, joiner }) => { + let displayValue; - if (Array.isArray(key)) { - // For combined keys, join their values if both are present - const [key1, key2] = key; - const value1 = prompt[key1]; - const value2 = prompt[key2]; - if (value1 && value2) { - displayValue = `${value1}${joiner || ""}${value2}`; - } - } else { - // For single keys, just get the value - displayValue = prompt[key]; - } + if (Array.isArray(key)) { + // For combined keys, join their values if both are present + const [key1, key2] = key; + const value1 = prompt[key1]; + const value2 = prompt[key2]; + if (value1 && value2) { + displayValue = `${value1}${joiner || ""}${value2}`; + } + } else { + // For single keys, just get the value + displayValue = prompt[key]; + } - if (!displayValue) return null; + if (!displayValue) return null; - return ( - - {label}: {displayValue}{extraText || ""} - {link && ( - - Docs - - )} - - ); - })} -
- ); + return ( + + {label}: {displayValue} + {extraText || ""} + {link && ( + + Docs + + )} + + ); + })} +
+ + ); };