commit 934f3e1e2bac870f90b9529076d73c8e83112407 Author: Rajuahamedkst Date: Thu Oct 30 22:44:47 2025 +0800 tryon diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..400bedc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +.env +.vercel diff --git a/index.js b/index.js new file mode 100644 index 0000000..34835e8 --- /dev/null +++ b/index.js @@ -0,0 +1,1976 @@ +const express = require('express'); +const app = express(); +const cors = require('cors'); +require('dotenv').config(); +const { createClient } = require('@supabase/supabase-js'); +const axios = require('axios'); +app.use(express.json({ limit: '50mb' })); // โ† Add limit here +app.use(express.urlencoded({ limit: '50mb', extended: true })); // โ† Add this too +const port = process.env.PORT || 5235; + +// Middleware +app.use(cors()); +app.use(express.json()); + +// ============================================ +// SUPABASE SETUP +// ============================================ +const supabase = createClient( + process.env.SUPABASE_URL, + process.env.SUPABASE_ANON_KEY +); + +console.log('โœ… Supabase client initialized'); + +const FASHN_API_KEY = process.env.FASHN_API_KEY; +const FASHN_API_URL = 'https://api.fashn.ai/v1'; + +// ============================================ +// SIMPLE TEST ENDPOINT (1 GARMENT) +// ============================================ +app.post('/api/test-fashn', async (req, res) => { + try { + const { modelImage, garmentImage } = req.body; + + console.log('\n๐Ÿงช TESTING FASHN.AI'); + console.log('Model:', modelImage?.substring(0, 50)); + console.log('Garment:', garmentImage?.substring(0, 50)); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + // Step 1: Submit job + console.log('\n๐Ÿ“ค Submitting to FASHN.ai...'); + + const submitResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: modelImage, + garment_image: garmentImage, + category: 'auto' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + console.log('โœ… Response:', JSON.stringify(submitResponse.data, null, 2)); + + if (!submitResponse.data.id) { + return res.json({ + success: false, + error: 'No job ID received', + response: submitResponse.data + }); + } + + const jobId = submitResponse.data.id; + console.log('โœ… Job created:', jobId); + + // Step 2: Poll for result + console.log('\nโณ Polling for result...'); + + const maxAttempts = 30; // 1 minute max + const pollInterval = 2000; // 2 seconds + + for (let i = 0; i < maxAttempts; i++) { + await new Promise(resolve => setTimeout(resolve, pollInterval)); + + console.log(`๐Ÿ”„ Attempt ${i + 1}/${maxAttempts}`); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${jobId}`, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}` + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“Š Status:', JSON.stringify(statusResponse.data, null, 2)); + + if (statusResponse.data.status === 'completed') { + let imageUrl = statusResponse.data.output?.[0] || + statusResponse.data.result || + statusResponse.data.image; + + console.log('โœ… COMPLETED!'); + console.log('๐Ÿ–ผ๏ธ Image:', imageUrl); + + return res.json({ + success: true, + message: 'FASHN.ai works!', + jobId: jobId, + imageUrl: imageUrl, + attempts: i + 1 + }); + } + + if (statusResponse.data.status === 'failed') { + console.log('โŒ FAILED:', statusResponse.data.error); + + return res.json({ + success: false, + error: 'FASHN.ai job failed', + details: statusResponse.data.error + }); + } + + console.log('โณ Still processing...'); + + } catch (pollError) { + if (pollError.response?.status === 404) { + console.log('โณ Not ready yet (404)'); + continue; + } + + console.log('โš ๏ธ Poll error:', pollError.response?.status, pollError.message); + continue; + } + } + + // Timeout + return res.json({ + success: false, + error: 'Timeout - FASHN.ai took too long', + jobId: jobId + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// TEST WITH 2 GARMENTS (SHIRT + PANT) +// ============================================ +app.post('/api/test-two-garments', async (req, res) => { + try { + const { modelImage, shirtImage, pantImage } = req.body; + + console.log('\n๐Ÿงช TESTING 2 GARMENTS (SHIRT + PANT)'); + console.log('Model:', modelImage?.substring(0, 50)); + console.log('Shirt:', shirtImage?.substring(0, 50)); + console.log('Pant:', pantImage?.substring(0, 50)); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + // STEP 1: Apply SHIRT first + console.log('\n๐Ÿ‘• STEP 1: Applying SHIRT...'); + + const shirtResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: modelImage, + garment_image: shirtImage, + category: 'tops' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const shirtJobId = shirtResponse.data.id; + console.log('โœ… Shirt job created:', shirtJobId); + + // Poll for shirt result + console.log('โณ Waiting for shirt...'); + let shirtResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${shirtJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Shirt attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + shirtResult = statusResponse.data.output?.[0]; + console.log('โœ… Shirt applied!'); + console.log('๐Ÿ–ผ๏ธ Intermediate image:', shirtResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application failed', + details: statusResponse.data.error + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Shirt poll error:', pollError.message); + } + } + } + + if (!shirtResult) { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application timeout' + }); + } + + // STEP 2: Apply PANT on top of shirt result + console.log('\n๐Ÿ‘– STEP 2: Applying PANT...'); + + const pantResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: shirtResult, + garment_image: pantImage, + category: 'bottoms' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const pantJobId = pantResponse.data.id; + console.log('โœ… Pant job created:', pantJobId); + + // Poll for pant result + console.log('โณ Waiting for pant...'); + let pantResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${pantJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Pant attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + pantResult = statusResponse.data.output?.[0]; + console.log('โœ… Pant applied!'); + console.log('๐Ÿ–ผ๏ธ Final image:', pantResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application failed', + details: statusResponse.data.error, + shirtResult: shirtResult + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Pant poll error:', pollError.message); + } + } + } + + if (!pantResult) { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application timeout', + shirtResult: shirtResult + }); + } + + // Return final result + console.log('\nโœ… PROCESS COMPLETED!'); + + return res.json({ + success: true, + message: 'Both garments applied successfully!', + steps: { + shirt: { + jobId: shirtJobId, + result: shirtResult + }, + pant: { + jobId: pantJobId, + result: pantResult + } + }, + finalImage: pantResult + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// VIRTUAL TRY-ON (FRONTEND INTEGRATION) +// ============================================ +app.post('/api/virtual-tryon', async (req, res) => { + try { + const { userId, userImage, wardrobeItems, selectedPose, selectedBackground, selectedEffect } = req.body; + + console.log('\n๐ŸŽจ VIRTUAL TRY-ON REQUEST'); + console.log('User ID:', userId); + console.log('Wardrobe Items:', wardrobeItems?.length, 'items'); + console.log('Pose:', selectedPose); + console.log('Background:', selectedBackground); + console.log('Effect:', selectedEffect); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + if (!userImage || !wardrobeItems || wardrobeItems.length === 0) { + return res.status(400).json({ + success: false, + error: 'userImage and wardrobeItems are required' + }); + } + + // Separate tops and bottoms + const tops = wardrobeItems.filter(item => item.typecategory === 'tops'); + const bottoms = wardrobeItems.filter(item => item.typecategory === 'bottoms'); + + console.log('๐Ÿ‘• Tops:', tops.length); + console.log('๐Ÿ‘– Bottoms:', bottoms.length); + + // Build the prompt for face-to-model + let modelPrompt = ''; + if (selectedEffect) { + // If selectedEffect is an object, get the description + const effectText = typeof selectedEffect === 'string' + ? selectedEffect + : selectedEffect?.description || ''; + modelPrompt += effectText; + } + if (selectedPose) { + // If selectedPose is an object, get the description + const poseText = typeof selectedPose === 'string' + ? selectedPose + : selectedPose?.description || ''; + modelPrompt += modelPrompt ? `, ${poseText}` : poseText; + } + + console.log('๐ŸŽญ Model Prompt:', modelPrompt || 'auto-inferred'); + + // STEP 1: Create avatar from face + console.log('\n๐Ÿ‘ค STEP 1: Creating avatar from face...'); + + const faceToModelResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'face-to-model', + inputs: { + face_image: userImage, + ...(modelPrompt && { prompt: modelPrompt }) + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const faceJobId = faceToModelResponse.data.id; + console.log('โœ… Face-to-model job created:', faceJobId); + + // Poll for avatar creation + console.log('โณ Waiting for avatar generation...'); + let currentImage = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${faceJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Avatar attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + currentImage = statusResponse.data.output?.[0]; + console.log('โœ… Avatar created from face!'); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'face-to-model', + error: 'Avatar creation failed', + details: statusResponse.data.error + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Avatar poll error:', pollError.message); + } + } + } + + if (!currentImage) { + return res.json({ + success: false, + step: 'face-to-model', + error: 'Avatar creation timeout' + }); + } + + const results = { + avatar: currentImage + }; + + // STEP 2: Apply tops if available + if (tops.length > 0) { + console.log('\n๐Ÿ‘• STEP 2: Applying tops...'); + + for (const top of tops) { + console.log(` Applying: ${top.name}`); + + const topResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: currentImage, + garment_image: top.image_url, + category: 'tops' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const topJobId = topResponse.data.id; + + // Poll for result + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${topJobId}`, + { headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` } } + ); + + if (statusResponse.data.status === 'completed') { + currentImage = statusResponse.data.output?.[0]; + console.log(` โœ… ${top.name} applied!`); + break; + } + + if (statusResponse.data.status === 'failed') { + console.log(` โŒ ${top.name} failed, skipping`); + break; + } + } catch (pollError) { + // Continue polling + } + } + } + + results.withTops = currentImage; + } + + // STEP 3: Apply bottoms if available + if (bottoms.length > 0) { + console.log('\n๐Ÿ‘– STEP 3: Applying bottoms...'); + + for (const bottom of bottoms) { + console.log(` Applying: ${bottom.name}`); + + const bottomResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: currentImage, + garment_image: bottom.image_url, + category: 'bottoms' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const bottomJobId = bottomResponse.data.id; + + // Poll for result + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${bottomJobId}`, + { headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` } } + ); + + if (statusResponse.data.status === 'completed') { + currentImage = statusResponse.data.output?.[0]; + console.log(` โœ… ${bottom.name} applied!`); + break; + } + + if (statusResponse.data.status === 'failed') { + console.log(` โŒ ${bottom.name} failed, skipping`); + break; + } + } catch (pollError) { + // Continue polling + } + } + } + + results.withBottoms = currentImage; + } + + // STEP 4: Change background if provided + if (selectedBackground) { + console.log('\n๐ŸŒ† STEP 4: Changing background...'); + + // If selectedBackground is an object, get the description + const backgroundText = typeof selectedBackground === 'string' + ? selectedBackground + : selectedBackground?.description || ''; + + if (!backgroundText) { + console.log(' โš ๏ธ No background description provided, skipping'); + } else { + const backgroundResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'background-change', + inputs: { + image: currentImage, + prompt: backgroundText + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const bgJobId = backgroundResponse.data.id; + + // Poll for result + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${bgJobId}`, + { headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` } } + ); + + if (statusResponse.data.status === 'completed') { + currentImage = statusResponse.data.output?.[0]; + console.log(' โœ… Background changed!'); + break; + } + + if (statusResponse.data.status === 'failed') { + console.log(' โš ๏ธ Background change failed, using previous result'); + break; + } + } catch (pollError) { + // Continue polling + } + } + + results.withBackground = currentImage; + } + } + + // Return final result + console.log('\nโœ… VIRTUAL TRY-ON COMPLETE!'); + console.log('๐Ÿ–ผ๏ธ Final Image:', currentImage); + + return res.json({ + success: true, + message: 'Virtual try-on completed successfully!', + userId: userId, + generatedImageUrl: currentImage, + results: results, + appliedItems: { + tops: tops.map(t => t.name), + bottoms: bottoms.map(b => b.name) + } + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// BACKGROUND CHANGE +// ============================================ +app.post('/api/change-background', async (req, res) => { + try { + const { image, prompt } = req.body; + + console.log('\n๐ŸŒ† CHANGING BACKGROUND'); + console.log('Image:', image?.substring(0, 50)); + console.log('Background Prompt:', prompt); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + if (!image || !prompt) { + return res.status(400).json({ + success: false, + error: 'image and prompt are required', + example: { + image: 'https://cdn.fashn.ai/xyz/output_0.png', + prompt: 'city street with buildings, urban background, busy downtown' + } + }); + } + + // Submit background change job + console.log('\n๐Ÿ“ค Submitting background change request...'); + + const changeResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'background-change', + inputs: { + image: image, + prompt: prompt + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + console.log('โœ… Response:', JSON.stringify(changeResponse.data, null, 2)); + + if (!changeResponse.data.id) { + return res.json({ + success: false, + error: 'No job ID received', + response: changeResponse.data + }); + } + + const jobId = changeResponse.data.id; + console.log('โœ… Background change job created:', jobId); + + // Poll for result + console.log('\nโณ Polling for background change...'); + + const maxAttempts = 30; + const pollInterval = 2000; + + for (let i = 0; i < maxAttempts; i++) { + await new Promise(resolve => setTimeout(resolve, pollInterval)); + + console.log(`๐Ÿ”„ Attempt ${i + 1}/${maxAttempts}`); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${jobId}`, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}` + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“Š Status:', JSON.stringify(statusResponse.data, null, 2)); + + if (statusResponse.data.status === 'completed') { + let imageUrl = statusResponse.data.output?.[0] || + statusResponse.data.result || + statusResponse.data.image; + + console.log('โœ… BACKGROUND CHANGED!'); + console.log('๐Ÿ–ผ๏ธ New Image:', imageUrl); + + return res.json({ + success: true, + message: 'Background changed successfully!', + jobId: jobId, + imageUrl: imageUrl, + prompt: prompt, + attempts: i + 1 + }); + } + + if (statusResponse.data.status === 'failed') { + console.log('โŒ FAILED:', statusResponse.data.error); + + return res.json({ + success: false, + error: 'Background change failed', + details: statusResponse.data.error + }); + } + + console.log('โณ Still processing...'); + + } catch (pollError) { + if (pollError.response?.status === 404) { + console.log('โณ Not ready yet (404)'); + continue; + } + + console.log('โš ๏ธ Poll error:', pollError.response?.status, pollError.message); + continue; + } + } + + // Timeout + return res.json({ + success: false, + error: 'Timeout - Background change took too long', + jobId: jobId + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// FACE TO MODEL (CREATE AVATAR FROM FACE) +// ============================================ +app.post('/api/face-to-model', async (req, res) => { + try { + const { faceImage, prompt, outputFormat } = req.body; + + console.log('\n๐Ÿ‘ค CREATING MODEL FROM FACE IMAGE'); + console.log('Face Image:', faceImage?.substring(0, 50)); + console.log('Prompt:', prompt || 'None (auto-inferred)'); + console.log('Output Format:', outputFormat || 'png'); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + if (!faceImage) { + return res.status(400).json({ + success: false, + error: 'faceImage is required', + example: { + faceImage: 'https://i.ibb.co/C3DCLgSD/fashn-try-on-1761233346758.png', + prompt: 'athletic build, confident', + outputFormat: 'png' + } + }); + } + + // Submit face-to-model job + console.log('\n๐Ÿ“ค Submitting face-to-model request...'); + + const requestBody = { + model_name: 'face-to-model', + inputs: { + face_image: faceImage + } + }; + + // Add optional parameters + if (prompt) { + requestBody.inputs.prompt = prompt; + } + if (outputFormat) { + requestBody.inputs.output_format = outputFormat; + } + + const createResponse = await axios.post( + `${FASHN_API_URL}/run`, + requestBody, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + console.log('โœ… Response:', JSON.stringify(createResponse.data, null, 2)); + + if (!createResponse.data.id) { + return res.json({ + success: false, + error: 'No job ID received', + response: createResponse.data + }); + } + + const jobId = createResponse.data.id; + console.log('โœ… Face-to-model job created:', jobId); + + // Poll for result + console.log('\nโณ Polling for avatar generation...'); + + const maxAttempts = 30; // 1 minute max + const pollInterval = 2000; // 2 seconds + + for (let i = 0; i < maxAttempts; i++) { + await new Promise(resolve => setTimeout(resolve, pollInterval)); + + console.log(`๐Ÿ”„ Attempt ${i + 1}/${maxAttempts}`); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${jobId}`, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}` + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“Š Status:', JSON.stringify(statusResponse.data, null, 2)); + + if (statusResponse.data.status === 'completed') { + let avatarUrl = statusResponse.data.output?.[0] || + statusResponse.data.result || + statusResponse.data.image; + + console.log('โœ… AVATAR CREATED FROM FACE!'); + console.log('๐Ÿ–ผ๏ธ Avatar Image:', avatarUrl); + + return res.json({ + success: true, + message: 'Avatar created from face successfully!', + jobId: jobId, + avatarImage: avatarUrl, + faceImage: faceImage, + prompt: prompt || 'auto-inferred', + attempts: i + 1, + note: 'You can now use this avatarImage for try-on' + }); + } + + if (statusResponse.data.status === 'failed') { + console.log('โŒ FAILED:', statusResponse.data.error); + + return res.json({ + success: false, + error: 'Face-to-model conversion failed', + details: statusResponse.data.error + }); + } + + console.log('โณ Still processing...'); + + } catch (pollError) { + if (pollError.response?.status === 404) { + console.log('โณ Not ready yet (404)'); + continue; + } + + console.log('โš ๏ธ Poll error:', pollError.response?.status, pollError.message); + continue; + } + } + + // Timeout + return res.json({ + success: false, + error: 'Timeout - Face-to-model took too long', + jobId: jobId + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// FACE TO MODEL + APPLY GARMENTS (COMPLETE WORKFLOW) +// ============================================ +app.post('/api/face-to-model-and-tryon', async (req, res) => { + try { + const { faceImage, prompt, shirtImage, pantImage, backgroundPrompt } = req.body; + + console.log('\n๐ŸŽฏ FACE-TO-MODEL + GARMENT TRY-ON WORKFLOW'); + console.log('Face Image:', faceImage?.substring(0, 50)); + console.log('Prompt:', prompt || 'auto-inferred'); + console.log('Shirt:', shirtImage?.substring(0, 50)); + console.log('Pant:', pantImage?.substring(0, 50)); + console.log('Background:', backgroundPrompt || 'None'); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + if (!faceImage || !shirtImage || !pantImage) { + return res.status(400).json({ + success: false, + error: 'faceImage, shirtImage, and pantImage are required' + }); + } + + // STEP 1: Create avatar from face + console.log('\n๐Ÿ‘ค STEP 1: Creating avatar from face...'); + + const faceToModelResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'face-to-model', + inputs: { + face_image: faceImage, + ...(prompt && { prompt }) + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const faceJobId = faceToModelResponse.data.id; + console.log('โœ… Face-to-model job created:', faceJobId); + + // Poll for avatar creation + console.log('โณ Waiting for avatar generation...'); + let avatarImage = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${faceJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Avatar attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + avatarImage = statusResponse.data.output?.[0]; + console.log('โœ… Avatar created from face!'); + console.log('๐Ÿ–ผ๏ธ Avatar:', avatarImage); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'face-to-model', + error: 'Avatar creation failed', + details: statusResponse.data.error + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Avatar poll error:', pollError.message); + } + } + } + + if (!avatarImage) { + return res.json({ + success: false, + step: 'face-to-model', + error: 'Avatar creation timeout' + }); + } + + // STEP 2: Apply SHIRT to avatar + console.log('\n๐Ÿ‘• STEP 2: Applying SHIRT to avatar...'); + + const shirtResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: avatarImage, + garment_image: shirtImage, + category: 'tops' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const shirtJobId = shirtResponse.data.id; + console.log('โœ… Shirt job created:', shirtJobId); + + // Poll for shirt result + console.log('โณ Waiting for shirt...'); + let shirtResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${shirtJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Shirt attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + shirtResult = statusResponse.data.output?.[0]; + console.log('โœ… Shirt applied!'); + console.log('๐Ÿ–ผ๏ธ With shirt:', shirtResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application failed', + details: statusResponse.data.error, + avatarImage: avatarImage + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Shirt poll error:', pollError.message); + } + } + } + + if (!shirtResult) { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application timeout', + avatarImage: avatarImage + }); + } + + // STEP 3: Apply PANT to shirt result + console.log('\n๐Ÿ‘– STEP 3: Applying PANT...'); + + const pantResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: shirtResult, + garment_image: pantImage, + category: 'bottoms' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const pantJobId = pantResponse.data.id; + console.log('โœ… Pant job created:', pantJobId); + + // Poll for pant result + console.log('โณ Waiting for pant...'); + let pantResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${pantJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Pant attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + pantResult = statusResponse.data.output?.[0]; + console.log('โœ… Pant applied!'); + console.log('๐Ÿ–ผ๏ธ Final result:', pantResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application failed', + details: statusResponse.data.error, + avatarImage: avatarImage, + shirtResult: shirtResult + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Pant poll error:', pollError.message); + } + } + } + + if (!pantResult) { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application timeout', + avatarImage: avatarImage, + shirtResult: shirtResult + }); + } + + // STEP 4: Change background if provided + let finalResult = pantResult; + let backgroundJobId = null; + + if (backgroundPrompt) { + console.log('\n๐ŸŒ† STEP 4: Changing BACKGROUND...'); + + const backgroundResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'background-change', + inputs: { + image: pantResult, + prompt: backgroundPrompt + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + backgroundJobId = backgroundResponse.data.id; + console.log('โœ… Background job created:', backgroundJobId); + + // Poll for background result + console.log('โณ Waiting for background change...'); + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${backgroundJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Background attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + finalResult = statusResponse.data.output?.[0]; + console.log('โœ… Background changed!'); + console.log('๐Ÿ–ผ๏ธ Final image:', finalResult); + break; + } + + if (statusResponse.data.status === 'failed') { + console.log('โš ๏ธ Background change failed, using garments-only result'); + console.log('Error:', statusResponse.data.error); + // Don't fail the whole request, just skip background change + break; + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Background poll error:', pollError.message); + } + } + } + } + + // Return final result + console.log('\nโœ… COMPLETE FACE-TO-MODEL + TRY-ON FINISHED!'); + + const response = { + success: true, + message: backgroundPrompt + ? 'Avatar created, garments applied, and background changed!' + : 'Avatar created from face and garments applied!', + steps: { + faceToModel: { + jobId: faceJobId, + result: avatarImage, + prompt: prompt || 'auto-inferred' + }, + shirt: { + jobId: shirtJobId, + result: shirtResult + }, + pant: { + jobId: pantJobId, + result: pantResult + } + }, + finalImage: finalResult + }; + + if (backgroundPrompt && backgroundJobId) { + response.steps.background = { + jobId: backgroundJobId, + result: finalResult, + prompt: backgroundPrompt + }; + } + + return res.json(response); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// MODEL CREATION ONLY (TEST POSES) +// ============================================ +app.post('/api/create-model', async (req, res) => { + try { + const { prompt } = req.body; + + console.log('\n๐ŸŽญ CREATING MODEL WITH FASHN.AI'); + console.log('Prompt:', prompt); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + if (!prompt) { + return res.status(400).json({ + success: false, + error: 'Prompt is required', + examples: [ + 'male fashion model, athletic build, power pose with hands on hips, confident stance, full body, white background', + 'female fashion model, elegant, sitting on chair with legs crossed, professional, studio lighting', + 'male model, tall and slim, walking pose, one leg forward, dynamic movement, urban background' + ] + }); + } + + // Submit model creation job + console.log('\n๐Ÿ“ค Submitting model creation request...'); + + const createResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'model-create', + inputs: { + prompt: prompt + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + console.log('โœ… Response:', JSON.stringify(createResponse.data, null, 2)); + + if (!createResponse.data.id) { + return res.json({ + success: false, + error: 'No job ID received', + response: createResponse.data + }); + } + + const jobId = createResponse.data.id; + console.log('โœ… Model creation job created:', jobId); + + // Poll for result + console.log('\nโณ Polling for model generation...'); + + const maxAttempts = 30; // 1 minute max + const pollInterval = 2000; // 2 seconds + + for (let i = 0; i < maxAttempts; i++) { + await new Promise(resolve => setTimeout(resolve, pollInterval)); + + console.log(`๐Ÿ”„ Attempt ${i + 1}/${maxAttempts}`); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${jobId}`, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}` + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“Š Status:', JSON.stringify(statusResponse.data, null, 2)); + + if (statusResponse.data.status === 'completed') { + let imageUrl = statusResponse.data.output?.[0] || + statusResponse.data.result || + statusResponse.data.image; + + console.log('โœ… MODEL CREATED!'); + console.log('๐Ÿ–ผ๏ธ Model Image:', imageUrl); + + return res.json({ + success: true, + message: 'Model created successfully!', + jobId: jobId, + modelImage: imageUrl, + prompt: prompt, + attempts: i + 1, + note: 'You can now use this modelImage URL for try-on' + }); + } + + if (statusResponse.data.status === 'failed') { + console.log('โŒ FAILED:', statusResponse.data.error); + + return res.json({ + success: false, + error: 'Model creation failed', + details: statusResponse.data.error + }); + } + + console.log('โณ Still processing...'); + + } catch (pollError) { + if (pollError.response?.status === 404) { + console.log('โณ Not ready yet (404)'); + continue; + } + + console.log('โš ๏ธ Poll error:', pollError.response?.status, pollError.message); + continue; + } + } + + // Timeout + return res.json({ + success: false, + error: 'Timeout - Model creation took too long', + jobId: jobId + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +// ============================================ +// CREATE MODEL WITH POSE + APPLY GARMENTS +// ============================================ +app.post('/api/create-model-and-tryon', async (req, res) => { + try { + const { posePrompt, shirtImage, pantImage, modelDescription } = req.body; + + console.log('\n๐Ÿงช CREATE MODEL WITH POSE + APPLY GARMENTS'); + console.log('Pose Prompt:', posePrompt); + console.log('Model Description:', modelDescription || 'Default model'); + console.log('Shirt:', shirtImage?.substring(0, 50)); + console.log('Pant:', pantImage?.substring(0, 50)); + + if (!FASHN_API_KEY) { + return res.status(500).json({ + success: false, + error: 'FASHN_API_KEY not set in .env' + }); + } + + // STEP 1: Create model with specific pose + console.log('\n๐ŸŽญ STEP 1: Creating model with pose...'); + + const fullPrompt = modelDescription + ? `${modelDescription}, ${posePrompt}` + : posePrompt; + + const modelCreateResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'model-create', + inputs: { + prompt: fullPrompt + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const modelJobId = modelCreateResponse.data.id; + console.log('โœ… Model creation job created:', modelJobId); + + // Poll for model creation result + console.log('โณ Waiting for model generation...'); + let generatedModel = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${modelJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Model attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + generatedModel = statusResponse.data.output?.[0]; + console.log('โœ… Model created with pose!'); + console.log('๐Ÿ–ผ๏ธ Generated model:', generatedModel); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'model-create', + error: 'Model creation failed', + details: statusResponse.data.error + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Model creation poll error:', pollError.message); + } + } + } + + if (!generatedModel) { + return res.json({ + success: false, + step: 'model-create', + error: 'Model creation timeout' + }); + } + + // STEP 2: Apply SHIRT to the generated model + console.log('\n๐Ÿ‘• STEP 2: Applying SHIRT to generated model...'); + + const shirtResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: generatedModel, + garment_image: shirtImage, + category: 'tops' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const shirtJobId = shirtResponse.data.id; + console.log('โœ… Shirt job created:', shirtJobId); + + // Poll for shirt result + console.log('โณ Waiting for shirt...'); + let shirtResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${shirtJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Shirt attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + shirtResult = statusResponse.data.output?.[0]; + console.log('โœ… Shirt applied!'); + console.log('๐Ÿ–ผ๏ธ With shirt:', shirtResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application failed', + details: statusResponse.data.error, + generatedModel: generatedModel + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Shirt poll error:', pollError.message); + } + } + } + + if (!shirtResult) { + return res.json({ + success: false, + step: 'shirt', + error: 'Shirt application timeout', + generatedModel: generatedModel + }); + } + + // STEP 3: Apply PANT to the shirt result + console.log('\n๐Ÿ‘– STEP 3: Applying PANT...'); + + const pantResponse = await axios.post( + `${FASHN_API_URL}/run`, + { + model_name: 'tryon-v1.6', + inputs: { + model_image: shirtResult, + garment_image: pantImage, + category: 'bottoms' + } + }, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + const pantJobId = pantResponse.data.id; + console.log('โœ… Pant job created:', pantJobId); + + // Poll for pant result + console.log('โณ Waiting for pant...'); + let pantResult = null; + + for (let i = 0; i < 30; i++) { + await new Promise(resolve => setTimeout(resolve, 2000)); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/status/${pantJobId}`, + { + headers: { 'Authorization': `Bearer ${FASHN_API_KEY}` }, + timeout: 10000 + } + ); + + console.log(`๐Ÿ”„ Pant attempt ${i + 1}/30 - Status: ${statusResponse.data.status}`); + + if (statusResponse.data.status === 'completed') { + pantResult = statusResponse.data.output?.[0]; + console.log('โœ… Pant applied!'); + console.log('๐Ÿ–ผ๏ธ Final result:', pantResult); + break; + } + + if (statusResponse.data.status === 'failed') { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application failed', + details: statusResponse.data.error, + generatedModel: generatedModel, + shirtResult: shirtResult + }); + } + } catch (pollError) { + if (pollError.response?.status !== 404) { + console.log('โš ๏ธ Pant poll error:', pollError.message); + } + } + } + + if (!pantResult) { + return res.json({ + success: false, + step: 'pant', + error: 'Pant application timeout', + generatedModel: generatedModel, + shirtResult: shirtResult + }); + } + + // Return final result + console.log('\nโœ… COMPLETE WORKFLOW FINISHED!'); + + return res.json({ + success: true, + message: 'Model created with pose and garments applied!', + steps: { + modelCreate: { + jobId: modelJobId, + result: generatedModel, + prompt: fullPrompt + }, + shirt: { + jobId: shirtJobId, + result: shirtResult + }, + pant: { + jobId: pantJobId, + result: pantResult + } + }, + finalImage: pantResult + }); + + } catch (error) { + console.error('โŒ ERROR:', error.response?.data || error.message); + + res.status(500).json({ + success: false, + error: error.message, + details: error.response?.data + }); + } +}); + +app.get('/api/products', async (req, res) => { + try { + const { data: products, error } = await supabase + .from('products') + .select('*'); + + if (error) { + throw error; + } + + res.json({ + success: true, + products: products || [] + }); + + } catch (error) { + console.error('โŒ Products error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.post('/api/addproducts', async (req, res) => { + try { + const { name, price, description, image_url, category } = req.body; + + // Basic validation + if (!name || !price || !description || !image_url || !category) { + return res.status(400).json({ + success: false, + error: 'All fields (name, price, description, image_url, category) are required' + }); + } + + // Insert into Supabase + const { data, error } = await supabase + .from('products') + .insert([ + { + name, + price, + description, + image_url, + category, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() + } + ]) + .select('*') + .single(); + + if (error) throw error; + + res.status(201).json({ + success: true, + message: 'โœ… Product created successfully', + product: data + }); + + } catch (error) { + console.error('โŒ Product insert error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.get('/api/backgrounds', async (req, res) => { + try { + const { data, error } = await supabase + .from('backgrounds') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + backgrounds: data || [] + }); + } catch (err) { + console.error('โŒ Backgrounds fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/poses', async (req, res) => { + try { + const { data, error } = await supabase + .from('poses') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + poses: data || [] + }); + } catch (err) { + console.error('โŒ Poses fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/effects', async (req, res) => { + try { + const { data, error } = await supabase + .from('effects') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + effects: data || [] + }); + } catch (err) { + console.error('โŒ Effects fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +// ============================================ +// ROOT +// ============================================ +app.get('/', (req, res) => { + res.json({ + message: 'FASHN.ai Test Server', + endpoints: { + virtualTryon: 'POST /api/virtual-tryon', + changeBackground: 'POST /api/change-background', + faceToModel: 'POST /api/face-to-model', + faceToModelAndTryon: 'POST /api/face-to-model-and-tryon', + createModel: 'POST /api/create-model', + singleGarment: 'POST /api/test-fashn', + twoGarments: 'POST /api/test-two-garments', + createModelAndTryon: 'POST /api/create-model-and-tryon' + }, + fashnApiKey: FASHN_API_KEY ? 'โœ… Configured' : 'โŒ Missing' + }); +}); + +// ============================================ +// START +// ============================================ +const PORT = 5235; +app.listen(PORT, () => { + console.log('\n========================================'); + console.log('๐Ÿงช FASHN.ai Test Server'); + console.log('========================================'); + console.log(`Server: http://localhost:${PORT}`); + console.log(`FASHN API Key: ${FASHN_API_KEY ? 'โœ… Set' : 'โŒ Not set'}`); + console.log('========================================\n'); +}); + +// ============================================ +// START SERVER (Local Development) +// ============================================ +if (process.env.NODE_ENV !== 'production') { + const PORT = process.env.PORT || 5235; + app.listen(PORT, () => { + console.log('\n========================================'); + console.log('๐Ÿงช FASHN.ai Test Server'); + console.log('========================================'); + console.log(`Server: http://localhost:${PORT}`); + console.log(`FASHN API Key: ${FASHN_API_KEY ? 'โœ… Set' : 'โŒ Not set'}`); + console.log('========================================\n'); + }); +} + +// ============================================ +// EXPORT FOR VERCEL (Serverless) +// ============================================ +module.exports = app; \ No newline at end of file diff --git a/index.js.txt b/index.js.txt new file mode 100644 index 0000000..fa372d8 --- /dev/null +++ b/index.js.txt @@ -0,0 +1,739 @@ +const express = require('express'); +const app = express(); +const cors = require('cors'); +require('dotenv').config(); +const { createClient } = require('@supabase/supabase-js'); +const Replicate = require('replicate'); +const { v4: uuidv4 } = require('uuid'); + +const port = process.env.PORT || 5235; + +// Middleware +app.use(cors()); +app.use(express.json()); + +// ============================================ +// SUPABASE SETUP +// ============================================ +const supabase = createClient( + process.env.SUPABASE_URL, + process.env.SUPABASE_ANON_KEY +); + +console.log('โœ… Supabase client initialized'); + +// ============================================ +// REPLICATE SETUP +// ============================================ +const replicate = new Replicate({ + auth: process.env.REPLICATE_API_TOKEN +}); + +// In-memory cache for faster status checks +const jobsCache = new Map(); + +// ============================================ +// HELPER FUNCTIONS +// ============================================ + +/** + * Build prompt from products and effects + */ +function buildPrompt(products, effect) { + const basePrompt = "professional fashion photography, full body shot, high quality, detailed, realistic, 8k"; + + const effectPrompts = { + 'sunset-lighting': 'warm sunset lighting, golden hour, soft shadows', + 'studio-lighting': 'professional studio lighting, clean background', + 'dramatic': 'dramatic lighting, high contrast, cinematic', + 'natural': 'natural daylight, outdoor setting', + 'vintage': 'vintage film photography, retro aesthetic', + 'modern': 'modern minimalist, clean aesthetic' + }; + + const effectDescription = effectPrompts[effect] || 'natural lighting'; + return `${basePrompt}, ${effectDescription}`; +} + +/** + * Generate image with Replicate + */ +async function generateWithReplicate(options) { + const { products, pose, background, effect } = options; + + try { + console.log('\n๐ŸŽจ Starting AI generation...'); + console.log('Products:', products.length); + console.log('Effect:', effect); + + const prompt = buildPrompt(products, effect); + console.log('Prompt:', prompt); + + // Prepare input + const input = { + prompt: prompt, + negative_prompt: "low quality, blurry, distorted, ugly, bad anatomy, extra limbs", + num_inference_steps: 30, + guidance_scale: 7.5, + width: 1024, + height: 1024 + }; + + // Add main product image + if (products && products.length > 0) { + input.image = products[0]; + input.prompt_strength = 0.8; + } + + // Add pose control + if (pose) { + input.control_image = pose; + input.control_type = 'openpose'; + input.controlnet_conditioning_scale = 0.8; + } + + // Stable Diffusion XL + const model = "stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b"; + + console.log('Calling Replicate API...'); + const startTime = Date.now(); + + const output = await replicate.run(model, { input }); + + const processingTime = Math.round((Date.now() - startTime) / 1000); + console.log(`โœ… Generation completed in ${processingTime}s`); + + const imageUrl = Array.isArray(output) ? output[0] : output; + return { imageUrl, processingTime }; + + } catch (error) { + console.error('โŒ Replicate error:', error); + throw error; + } +} +/** + * Process job in background + */ +async function processJob(jobId) { + try { + console.log(`\n๐Ÿ“‹ Processing job: ${jobId}`); + + // Get job from Supabase + const { data: job, error: fetchError } = await supabase + .from('generation_jobs') + .select('*') + .eq('job_id', jobId) + .single(); + + if (fetchError || !job) { + throw new Error('Job not found'); + } + + // Update status to processing + await supabase + .from('generation_jobs') + .update({ + status: 'processing', + progress: 20 + }) + .eq('job_id', jobId); + + jobsCache.set(jobId, { status: 'processing', progress: 20 }); + console.log('Status: processing'); + + // Generate image + const { imageUrl, processingTime } = await generateWithReplicate({ + products: job.product_urls, + pose: job.pose_url, + background: job.background_url, + effect: job.effect + }); + + // Update with result + const { error: updateError } = await supabase + .from('generation_jobs') + .update({ + status: 'completed', + progress: 100, + generated_image_url: imageUrl, + processing_time: processingTime, + completed_at: new Date().toISOString() + }) + .eq('job_id', jobId); + + if (updateError) { + throw updateError; + } + + jobsCache.set(jobId, { + status: 'completed', + progress: 100, + imageUrl: imageUrl + }); + + console.log(`โœ… Job ${jobId} completed!`); + console.log(`Image: ${imageUrl}`); + + } catch (error) { + console.error(`โŒ Job ${jobId} failed:`, error); + + // Update as failed + await supabase + .from('generation_jobs') + .update({ + status: 'failed', + error: error.message, + completed_at: new Date().toISOString() + }) + .eq('job_id', jobId); + + jobsCache.set(jobId, { + status: 'failed', + error: error.message + }); + } +} + +// ============================================ +// API ROUTES +// ============================================ + +/** + * POST /api/generate + * Create new generation job + */ +app.post('/api/generate', async (req, res) => { + try { + const { + userId, + userImage, + wardrobeItems, + selectedPose, + selectedBackground, + selectedEffect + } = req.body; + + console.log('\n๐Ÿ†• New generation request'); + console.log('User:', userId); + console.log('Wardrobe items:', wardrobeItems?.length || 0); + console.log('User image:', userImage ? 'Yes' : 'No'); + console.log('Background:', selectedBackground?.name); + console.log('Pose:', selectedPose?.name); + console.log('Effect:', selectedEffect?.name); + + // Validation + if (!wardrobeItems || wardrobeItems.length === 0) { + return res.status(400).json({ + success: false, + error: 'At least one wardrobe item is required' + }); + } + + if (!userImage) { + return res.status(400).json({ + success: false, + error: 'User image is required' + }); + } + + // Generate job ID + const jobId = uuidv4(); + console.log('Job ID:', jobId); + + // Extract image URLs from wardrobe items + const productUrls = wardrobeItems.map(item => item.image_url); + + // Insert into Supabase + const { error: insertError } = await supabase + .from('generation_jobs') + .insert({ + job_id: jobId, + user_id: userId || 'guest', + user_image: userImage, + product_urls: productUrls, + products: wardrobeItems, + pose_url: selectedPose?.pose_image_url, + pose: selectedPose, + background_url: selectedBackground?.bg_image_url, + background: selectedBackground, + effect: selectedEffect?.name || 'natural', + effect_data: selectedEffect, + status: 'queued', + progress: 0, + created_at: new Date().toISOString() + }); + + if (insertError) { + console.error('Supabase insert error:', insertError); + throw insertError; + } + + console.log('โœ… Job created in Supabase'); + + // Cache in memory + jobsCache.set(jobId, { status: 'queued', progress: 0 }); + + // Process in background + setImmediate(() => { + processJob(jobId).catch(err => { + console.error('Background processing error:', err); + }); + }); + + // Return response + res.status(201).json({ + success: true, + jobId, + status: 'queued', + message: 'Generation job created successfully', + estimatedTime: '30-60 seconds' + }); + + } catch (error) { + console.error('โŒ Generate error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +/** + * POST /api/products + * Add a new product + */ +app.post('/api/addproducts', async (req, res) => { + try { + const { name, price, description, image_url, category } = req.body; + + // Basic validation + if (!name || !price || !description || !image_url || !category) { + return res.status(400).json({ + success: false, + error: 'All fields (name, price, description, image_url, category) are required' + }); + } + + // Insert into Supabase + const { data, error } = await supabase + .from('products') + .insert([ + { + name, + price, + description, + image_url, + category, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() + } + ]) + .select('*') + .single(); + + if (error) throw error; + + res.status(201).json({ + success: true, + message: 'โœ… Product created successfully', + product: data + }); + + } catch (error) { + console.error('โŒ Product insert error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.get('/api/backgrounds', async (req, res) => { + try { + const { data, error } = await supabase + .from('backgrounds') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + backgrounds: data || [] + }); + } catch (err) { + console.error('โŒ Backgrounds fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/poses', async (req, res) => { + try { + const { data, error } = await supabase + .from('poses') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + poses: data || [] + }); + } catch (err) { + console.error('โŒ Poses fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/effects', async (req, res) => { + try { + const { data, error } = await supabase + .from('effects') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + effects: data || [] + }); + } catch (err) { + console.error('โŒ Effects fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + + +/** + * GET /api/job-status/:jobId + * Get job status + */ +app.get('/api/job-status/:jobId', async (req, res) => { + try { + const { jobId } = req.params; + + // Check cache first (faster) + let cachedJob = jobsCache.get(jobId); + + // Get from Supabase + const { data: job, error } = await supabase + .from('generation_jobs') + .select('*') + .eq('job_id', jobId) + .single(); + + if (error || !job) { + return res.status(404).json({ + success: false, + error: 'Job not found' + }); + } + + // Update cache + jobsCache.set(jobId, { + status: job.status, + progress: job.progress, + imageUrl: job.generated_image_url + }); + + res.json({ + success: true, + jobId: job.job_id, + status: job.status, + progress: job.progress, + generatedImageUrl: job.generated_image_url, + error: job.error, + createdAt: job.created_at, + completedAt: job.completed_at, + processingTime: job.processing_time + }); + + } catch (error) { + console.error('โŒ Status check error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + + +/** + * GET /api/user-history/:userId + * Get user's generation history + */ +app.get('/api/user-history/:userId', async (req, res) => { + try { + const { userId } = req.params; + const limit = parseInt(req.query.limit) || 20; + const offset = parseInt(req.query.skip) || 0; + + const { data: jobs, error, count } = await supabase + .from('generation_jobs') + .select('*', { count: 'exact' }) + .eq('user_id', userId) + .order('created_at', { ascending: false }) + .range(offset, offset + limit - 1); + + if (error) { + throw error; + } + + res.json({ + success: true, + jobs: jobs || [], + total: count || 0, + limit, + skip: offset + }); + + } catch (error) { + console.error('โŒ History error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + + +/** + * GET /api/generation-stats + * Get generation statistics + */ +app.get('/api/generation-stats', async (req, res) => { + try { + // Get total count + const { count: total } = await supabase + .from('generation_jobs') + .select('*', { count: 'exact', head: true }); + + // Get completed count + const { count: completed } = await supabase + .from('generation_jobs') + .select('*', { count: 'exact', head: true }) + .eq('status', 'completed'); + + // Get failed count + const { count: failed } = await supabase + .from('generation_jobs') + .select('*', { count: 'exact', head: true }) + .eq('status', 'failed'); + + // Get processing count + const { count: processing } = await supabase + .from('generation_jobs') + .select('*', { count: 'exact', head: true }) + .eq('status', 'processing'); + + // Get average processing time + const { data: avgData } = await supabase + .from('generation_jobs') + .select('processing_time') + .eq('status', 'completed') + .not('processing_time', 'is', null); + + const avgProcessingTime = avgData && avgData.length > 0 + ? Math.round(avgData.reduce((sum, job) => sum + (job.processing_time || 0), 0) / avgData.length) + : 0; + + res.json({ + success: true, + stats: { + total: total || 0, + completed: completed || 0, + failed: failed || 0, + processing: processing || 0, + averageProcessingTime: avgProcessingTime, + successRate: total > 0 ? `${((completed / total) * 100).toFixed(1)}%` : 'N/A' + } + }); + + } catch (error) { + console.error('โŒ Stats error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + + +/** + * GET /api/products + * Get all products from Supabase + */ +app.get('/api/products', async (req, res) => { + try { + const { data: products, error } = await supabase + .from('products') + .select('*'); + + if (error) { + throw error; + } + + res.json({ + success: true, + products: products || [] + }); + + } catch (error) { + console.error('โŒ Products error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +/** + * GET /api/products/:id + * Get single product + */ +app.get('/api/products/:id', async (req, res) => { + try { + const { data: product, error } = await supabase + .from('products') + .select('*') + .eq('id', req.params.id) + .single(); + + if (error || !product) { + return res.status(404).json({ + success: false, + error: 'Product not found' + }); + } + + res.json({ + success: true, + product + }); + + } catch (error) { + console.error('โŒ Product error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +/** + * GET /api/health + * Health check + */ +app.get('/api/health', async (req, res) => { + try { + // Check Supabase connection + const { error: supabaseError } = await supabase + .from('generation_jobs') + .select('job_id', { count: 'exact', head: true }) + .limit(1); + + const supabaseStatus = supabaseError ? 'error' : 'connected'; + + // Check Replicate + let replicateStatus = 'unknown'; + try { + await replicate.models.list({ limit: 1 }); + replicateStatus = 'connected'; + } catch (err) { + replicateStatus = 'error'; + } + + res.json({ + success: true, + status: 'healthy', + services: { + supabase: supabaseStatus, + replicate: replicateStatus + }, + stats: { + jobsInCache: jobsCache.size + }, + timestamp: new Date().toISOString() + }); + + } catch (error) { + res.status(503).json({ + success: false, + error: error.message + }); + } +}); + +// ============================================ +// ROOT ROUTE +// ============================================ + +app.get('/', (req, res) => { + res.json({ + message: 'Virtual Try-On Server with Supabase', + version: '1.0.0', + database: 'Supabase (PostgreSQL)', + endpoints: { + generate: 'POST /api/generate', + jobStatus: 'GET /api/job-status/:jobId', + userHistory: 'GET /api/user-history/:userId', + stats: 'GET /api/generation-stats', + products: 'GET /api/products', + product: 'GET /api/products/:id', + health: 'GET /api/health' + } + }); +}); + +// ============================================ +// ERROR HANDLING +// ============================================ + +app.use((req, res) => { + res.status(404).json({ + success: false, + error: 'Endpoint not found', + path: req.path + }); +}); + +app.use((err, req, res, next) => { + console.error('โŒ Unhandled error:', err); + res.status(500).json({ + success: false, + error: 'Internal server error', + message: err.message + }); +}); + +// ============================================ +// START SERVER +// ============================================ + +// For Vercel serverless functions, export the app +if (process.env.NODE_ENV === 'production') { + // Export for Vercel serverless + module.exports = app; +} else { + // Local development + app.listen(port, () => { + console.log('\n' + '='.repeat(60)); + console.log('๐Ÿš€ Virtual Try-On Server with Supabase'); + console.log('='.repeat(60)); + console.log(`๐Ÿ“ก Server: http://localhost:${port}`); + console.log(`๐Ÿ’พ Database: Supabase (PostgreSQL)`); + console.log(`๐Ÿ“Š Health: http://localhost:${port}/api/health`); + console.log('='.repeat(60) + '\n'); + }); +} \ No newline at end of file diff --git a/index.txt b/index.txt new file mode 100644 index 0000000..e07ff5b --- /dev/null +++ b/index.txt @@ -0,0 +1,135 @@ +app.get('/api/products', async (req, res) => { + try { + const { data: products, error } = await supabase + .from('products') + .select('*'); + + if (error) { + throw error; + } + + res.json({ + success: true, + products: products || [] + }); + + } catch (error) { + console.error('โŒ Products error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.post('/api/addproducts', async (req, res) => { + try { + const { name, price, description, image_url, category } = req.body; + + // Basic validation + if (!name || !price || !description || !image_url || !category) { + return res.status(400).json({ + success: false, + error: 'All fields (name, price, description, image_url, category) are required' + }); + } + + // Insert into Supabase + const { data, error } = await supabase + .from('products') + .insert([ + { + name, + price, + description, + image_url, + category, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() + } + ]) + .select('*') + .single(); + + if (error) throw error; + + res.status(201).json({ + success: true, + message: 'โœ… Product created successfully', + product: data + }); + + } catch (error) { + console.error('โŒ Product insert error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.get('/api/backgrounds', async (req, res) => { + try { + const { data, error } = await supabase + .from('backgrounds') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + backgrounds: data || [] + }); + } catch (err) { + console.error('โŒ Backgrounds fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/poses', async (req, res) => { + try { + const { data, error } = await supabase + .from('poses') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + poses: data || [] + }); + } catch (err) { + console.error('โŒ Poses fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/effects', async (req, res) => { + try { + const { data, error } = await supabase + .from('effects') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + effects: data || [] + }); + } catch (err) { + console.error('โŒ Effects fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); \ No newline at end of file diff --git a/new.txt b/new.txt new file mode 100644 index 0000000..e1b2bab --- /dev/null +++ b/new.txt @@ -0,0 +1,675 @@ +const express = require('express'); +const app = express(); +const cors = require('cors'); +require('dotenv').config(); +const { createClient } = require('@supabase/supabase-js'); +const axios = require('axios'); +const { v4: uuidv4 } = require('uuid'); +app.use(express.json({ limit: '50mb' })); // โ† Add limit here +app.use(express.urlencoded({ limit: '50mb', extended: true })); // โ† Add this too +const port = process.env.PORT || 5235; + +// Middleware +app.use(cors()); +app.use(express.json()); + +// ============================================ +// SUPABASE SETUP +// ============================================ +const supabase = createClient( + process.env.SUPABASE_URL, + process.env.SUPABASE_ANON_KEY +); + +console.log('โœ… Supabase client initialized'); + +// ============================================ +// FASHN.AI SETUP +// ============================================ +const FASHN_API_KEY = process.env.FASHN_API_KEY; +const FASHN_API_URL = 'https://api.fashn.ai/v1'; + +// In-memory cache +const jobsCache = new Map(); + +// ============================================ +// FASHN.AI HELPER FUNCTIONS +// ============================================ + +/** + * Convert blob/data URL to public URL - Upload to Supabase Storage + */ +async function uploadImageToStorage(imageData, userId, fileName) { + try { + console.log('๐Ÿ“ค Uploading image to Supabase Storage...'); + + let fileBuffer; + let contentType = 'image/jpeg'; + + if (imageData.startsWith('data:')) { + const matches = imageData.match(/^data:([^;]+);base64,(.+)$/); + if (!matches) { + throw new Error('Invalid data URL format'); + } + contentType = matches[1]; + const base64Data = matches[2]; + fileBuffer = Buffer.from(base64Data, 'base64'); + } else if (imageData.startsWith('blob:')) { + throw new Error('Blob URLs cannot be uploaded. Please convert to base64 first.'); + } else { + return imageData; + } + + const filePath = `${userId}/${fileName}_${Date.now()}.jpg`; + + const { data, error } = await supabase.storage + .from('user-uploads') + .upload(filePath, fileBuffer, { + contentType: contentType, + upsert: false + }); + + if (error) { + console.error('Supabase storage error:', error); + throw error; + } + + const { data: urlData } = supabase.storage + .from('user-uploads') + .getPublicUrl(filePath); + + console.log('โœ… Image uploaded:', urlData.publicUrl); + return urlData.publicUrl; + + } catch (error) { + console.error('โŒ Upload error:', error); + throw new Error(`Failed to upload image: ${error.message}`); + } +} + +/** + * Apply single garment using FASHN.ai with polling + */ +async function applyGarmentWithFashn(modelImage, garmentImage) { + try { + console.log('๐Ÿ“ค Calling FASHN.ai API...'); + console.log('Model image:', modelImage.substring(0, 80) + '...'); + console.log('Garment image:', garmentImage.substring(0, 80) + '...'); + + if (modelImage.startsWith('blob:') || modelImage.startsWith('data:')) { + throw new Error('Model image must be a public URL'); + } + + const startTime = Date.now(); + + // Step 1: Submit job + const requestBody = { + model_image: modelImage, + garment_image: garmentImage, + category: 'auto' + }; + + console.log('๐Ÿ“ค Submitting job to FASHN.ai...'); + + const submitResponse = await axios.post( + `${FASHN_API_URL}/run`, + requestBody, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}`, + 'Content-Type': 'application/json' + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“ฅ Submission response:', JSON.stringify(submitResponse.data, null, 2)); + + if (!submitResponse.data || !submitResponse.data.id) { + throw new Error('No job ID received from FASHN.ai'); + } + + const jobId = submitResponse.data.id; + console.log('โœ… FASHN.ai job created:', jobId); + + // Step 2: Poll for result + console.log('โณ Polling for result...'); + + const maxAttempts = 60; + const pollInterval = 2000; + let attempts = 0; + + while (attempts < maxAttempts) { + await new Promise(resolve => setTimeout(resolve, pollInterval)); + attempts++; + + console.log(`๐Ÿ”„ Checking status (attempt ${attempts}/${maxAttempts})...`); + + try { + const statusResponse = await axios.get( + `${FASHN_API_URL}/${jobId}`, + { + headers: { + 'Authorization': `Bearer ${FASHN_API_KEY}` + }, + timeout: 10000 + } + ); + + console.log('๐Ÿ“Š Status response:', JSON.stringify(statusResponse.data, null, 2)); + + if (statusResponse.data.status === 'completed') { + const processingTime = Math.round((Date.now() - startTime) / 1000); + + let imageUrl = null; + + if (statusResponse.data.output && Array.isArray(statusResponse.data.output)) { + imageUrl = statusResponse.data.output[0]; + } else if (statusResponse.data.result) { + imageUrl = statusResponse.data.result; + } else if (statusResponse.data.image) { + imageUrl = statusResponse.data.image; + } + + if (imageUrl) { + console.log(`โœ… FASHN.ai completed in ${processingTime}s`); + console.log(`๐Ÿ–ผ๏ธ Result URL: ${imageUrl}`); + return { imageUrl, processingTime }; + } else { + console.error('โŒ No image URL in completed response'); + console.error('Full response:', JSON.stringify(statusResponse.data, null, 2)); + throw new Error('Job completed but no image URL found'); + } + } + + if (statusResponse.data.status === 'failed') { + throw new Error(`FASHN.ai job failed: ${statusResponse.data.error || 'Unknown error'}`); + } + + console.log('โณ Status:', statusResponse.data.status || 'processing'); + + } catch (pollError) { + if (pollError.response) { + console.log(`โš ๏ธ Poll error - Status: ${pollError.response.status}`); + console.log(`โš ๏ธ Response:`, JSON.stringify(pollError.response.data, null, 2)); + + if (pollError.response.status === 404) { + console.log('โณ Job not ready yet (404)...'); + continue; + } + } else { + console.log('โš ๏ธ Poll error:', pollError.message); + } + + // Continue polling on errors + continue; + } + } + + throw new Error('FASHN.ai processing timeout'); + + } catch (error) { + if (error.response) { + console.error('โŒ FASHN.ai API error:'); + console.error('Status:', error.response.status); + console.error('Data:', JSON.stringify(error.response.data, null, 2)); + throw new Error(`FASHN.ai API error (${error.response.status}): ${error.response.data.message || error.response.statusText}`); + } else if (error.request) { + console.error('โŒ No response from FASHN.ai'); + throw new Error('FASHN.ai did not respond'); + } else { + console.error('โŒ FASHN.ai error:', error.message); + throw error; + } + } +} + +/** + * Layer wardrobe items sequentially + */ +async function layerWardrobeItems(userImage, wardrobeItems, userId) { + let currentImage = userImage; + const steps = []; + + console.log(`\n๐Ÿ‘• Layering ${wardrobeItems.length} wardrobe items...`); + + if (userImage.startsWith('blob:') || userImage.startsWith('data:')) { + console.log('๐Ÿ”„ Converting user image to public URL...'); + currentImage = await uploadImageToStorage(userImage, userId, 'user_image'); + } + + for (let i = 0; i < wardrobeItems.length; i++) { + const item = wardrobeItems[i]; + console.log(`\n๐Ÿ“ฆ Step ${i + 1}/${wardrobeItems.length}: Adding ${item.name}`); + + try { + const result = await applyGarmentWithFashn(currentImage, item.image_url); + + currentImage = result.imageUrl; + steps.push({ + step: i + 1, + item: item.name, + resultUrl: currentImage, + processingTime: result.processingTime + }); + + console.log(`โœ… ${item.name} applied successfully`); + + } catch (error) { + console.error(`โŒ Failed to apply ${item.name}:`, error.message); + throw new Error(`Failed to apply ${item.name}: ${error.message}`); + } + } + + console.log('\nโœ… All wardrobe items applied!'); + return { finalImage: currentImage, steps }; +} + +/** + * Process job in background + */ +async function processJob(jobId) { + try { + console.log(`\n๐ŸŽฌ ========================================`); + console.log(`๐Ÿ“‹ Processing job: ${jobId}`); + console.log(`๐ŸŽฌ ========================================`); + + const { data: job, error: fetchError } = await supabase + .from('generation_jobs') + .select('*') + .eq('job_id', jobId) + .single(); + + if (fetchError || !job) { + throw new Error('Job not found'); + } + + await supabase + .from('generation_jobs') + .update({ status: 'processing', progress: 10 }) + .eq('job_id', jobId); + + jobsCache.set(jobId, { status: 'processing', progress: 10 }); + + const userImage = job.user_image; + const wardrobeItems = job.products || []; + + console.log('\n๐Ÿ“ฆ Job Details:'); + console.log('User image:', userImage ? 'Yes' : 'No'); + console.log('Wardrobe items:', wardrobeItems.length); + + await supabase + .from('generation_jobs') + .update({ progress: 20 }) + .eq('job_id', jobId); + jobsCache.set(jobId, { status: 'processing', progress: 20 }); + + const { finalImage, steps } = await layerWardrobeItems(userImage, wardrobeItems, job.user_id); + + const progressPerItem = 60 / wardrobeItems.length; + for (let i = 0; i < steps.length; i++) { + const newProgress = 20 + Math.round((i + 1) * progressPerItem); + await supabase + .from('generation_jobs') + .update({ progress: newProgress }) + .eq('job_id', jobId); + jobsCache.set(jobId, { status: 'processing', progress: newProgress }); + } + + const totalProcessingTime = steps.reduce((sum, step) => sum + step.processingTime, 0); + + await supabase + .from('generation_jobs') + .update({ + status: 'completed', + progress: 100, + generated_image_url: finalImage, + processing_time: totalProcessingTime, + processing_steps: steps, + completed_at: new Date().toISOString() + }) + .eq('job_id', jobId); + + jobsCache.set(jobId, { + status: 'completed', + progress: 100, + imageUrl: finalImage + }); + + console.log(`\nโœ… ========================================`); + console.log(`โœ… Job ${jobId} COMPLETED!`); + console.log(`โœ… ========================================`); + console.log(`๐Ÿ–ผ๏ธ Final image: ${finalImage}`); + + } catch (error) { + console.error(`\nโŒ Job ${jobId} FAILED!`); + console.error(`โŒ Error:`, error.message); + + await supabase + .from('generation_jobs') + .update({ + status: 'failed', + error: error.message, + completed_at: new Date().toISOString() + }) + .eq('job_id', jobId); + + jobsCache.set(jobId, { + status: 'failed', + error: error.message + }); + } +} + +// ============================================ +// API ROUTES +// ============================================ + +app.post('/api/generate', async (req, res) => { + try { + const { userId, userImage, wardrobeItems, selectedPose, selectedBackground, selectedEffect } = req.body; + + console.log('\n๐Ÿ†• ========================================'); + console.log('๐Ÿ†• NEW GENERATION REQUEST'); + console.log('๐Ÿ†• ========================================'); + console.log('User:', userId); + console.log('Wardrobe items:', wardrobeItems?.length || 0); + + if (!wardrobeItems || wardrobeItems.length === 0) { + return res.status(400).json({ success: false, error: 'At least one wardrobe item required' }); + } + + if (!userImage) { + return res.status(400).json({ success: false, error: 'User image required' }); + } + + if (!FASHN_API_KEY) { + return res.status(500).json({ success: false, error: 'FASHN_API_KEY not configured' }); + } + + const jobId = uuidv4(); + console.log('Job ID:', jobId); + + const productUrls = wardrobeItems.map(item => item.image_url); + + const { error: insertError } = await supabase + .from('generation_jobs') + .insert({ + job_id: jobId, + user_id: userId || 'guest', + user_image: userImage, + product_urls: productUrls, + products: wardrobeItems, + pose_url: selectedPose?.pose_image_url, + pose: selectedPose, + background_url: selectedBackground?.bg_image_url, + background: selectedBackground, + effect: selectedEffect?.name || 'natural', + effect_data: selectedEffect, + status: 'queued', + progress: 0, + created_at: new Date().toISOString() + }); + + if (insertError) { + console.error('Supabase error:', insertError); + throw insertError; + } + + console.log('โœ… Job created in database'); + + jobsCache.set(jobId, { status: 'queued', progress: 0 }); + + setImmediate(() => { + processJob(jobId).catch(err => console.error('Processing error:', err)); + }); + + const estimatedTime = wardrobeItems.length * 15; + + res.status(201).json({ + success: true, + jobId, + status: 'queued', + message: 'Generation job created', + wardrobeItemsCount: wardrobeItems.length, + estimatedTime: `${estimatedTime}-${estimatedTime + 30} seconds` + }); + + } catch (error) { + console.error('โŒ Generate error:', error); + res.status(500).json({ success: false, error: error.message }); + } +}); + +app.get('/api/job-status/:jobId', async (req, res) => { + try { + const { jobId } = req.params; + + const { data: job, error } = await supabase + .from('generation_jobs') + .select('*') + .eq('job_id', jobId) + .single(); + + if (error || !job) { + return res.status(404).json({ success: false, error: 'Job not found' }); + } + + jobsCache.set(jobId, { + status: job.status, + progress: job.progress, + imageUrl: job.generated_image_url + }); + + res.json({ + success: true, + jobId: job.job_id, + status: job.status, + progress: job.progress, + generatedImageUrl: job.generated_image_url, + processingSteps: job.processing_steps, + error: job.error, + createdAt: job.created_at, + completedAt: job.completed_at, + processingTime: job.processing_time + }); + + } catch (error) { + console.error('โŒ Status error:', error); + res.status(500).json({ success: false, error: error.message }); + } +}); + +app.get('/api/health', async (req, res) => { + try { + const { error: supabaseError } = await supabase + .from('generation_jobs') + .select('job_id', { count: 'exact', head: true }) + .limit(1); + + const supabaseStatus = supabaseError ? 'error' : 'connected'; + const fashnStatus = FASHN_API_KEY ? 'configured' : 'not_configured'; + + res.json({ + success: true, + status: 'healthy', + services: { supabase: supabaseStatus, fashn: fashnStatus }, + stats: { jobsInCache: jobsCache.size } + }); + + } catch (error) { + res.status(503).json({ success: false, error: error.message }); + } +}); + +app.get('/api/products', async (req, res) => { + try { + const { data: products, error } = await supabase + .from('products') + .select('*'); + + if (error) { + throw error; + } + + res.json({ + success: true, + products: products || [] + }); + + } catch (error) { + console.error('โŒ Products error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.post('/api/addproducts', async (req, res) => { + try { + const { name, price, description, image_url, category } = req.body; + + // Basic validation + if (!name || !price || !description || !image_url || !category) { + return res.status(400).json({ + success: false, + error: 'All fields (name, price, description, image_url, category) are required' + }); + } + + // Insert into Supabase + const { data, error } = await supabase + .from('products') + .insert([ + { + name, + price, + description, + image_url, + category, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString() + } + ]) + .select('*') + .single(); + + if (error) throw error; + + res.status(201).json({ + success: true, + message: 'โœ… Product created successfully', + product: data + }); + + } catch (error) { + console.error('โŒ Product insert error:', error); + res.status(500).json({ + success: false, + error: error.message + }); + } +}); + +app.get('/api/backgrounds', async (req, res) => { + try { + const { data, error } = await supabase + .from('backgrounds') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + backgrounds: data || [] + }); + } catch (err) { + console.error('โŒ Backgrounds fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/poses', async (req, res) => { + try { + const { data, error } = await supabase + .from('poses') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + poses: data || [] + }); + } catch (err) { + console.error('โŒ Poses fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/api/effects', async (req, res) => { + try { + const { data, error } = await supabase + .from('effects') + .select('*') + .order('id', { ascending: true }); + + if (error) throw error; + + res.json({ + success: true, + effects: data || [] + }); + } catch (err) { + console.error('โŒ Effects fetch error:', err); + res.status(500).json({ + success: false, + error: err.message + }); + } +}); + +app.get('/', (req, res) => { + res.json({ + message: 'Virtual Try-On Server with FASHN.ai', + version: '2.0.0', + database: 'Supabase', + aiProvider: 'FASHN.ai' + }); +}); + +app.use((req, res) => { + res.status(404).json({ success: false, error: 'Endpoint not found' }); +}); + +app.use((err, req, res, next) => { + console.error('โŒ Error:', err); + res.status(500).json({ success: false, error: 'Internal server error' }); +}); + +app.listen(port, () => { + console.log('\n' + '='.repeat(70)); + console.log('๐Ÿš€ Virtual Try-On Server with FASHN.ai - EXACT PRODUCTS VERSION'); + console.log('='.repeat(70)); + console.log(`๐Ÿ“ก Server: http://localhost:${port}`); + console.log(`๐Ÿ’พ Database: Supabase`); + console.log(`๐Ÿค– AI Provider: FASHN.ai`); + console.log(`๐Ÿ“Š Health: http://localhost:${port}/api/health`); + console.log('='.repeat(70)); + + if (!FASHN_API_KEY) { + console.log('\nโš ๏ธ WARNING: FASHN_API_KEY not found!'); + } else { + console.log('\nโœ… FASHN API Key configured'); + } + console.log('\n'); +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..cfc3905 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1643 @@ +{ + "name": "virtual-tryon-backend", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "virtual-tryon-backend", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@supabase/supabase-js": "^2.76.1", + "axios": "^1.12.2", + "cors": "^2.8.5", + "dotenv": "^17.2.3", + "express": "^5.1.0", + "nodemon": "^3.1.10", + "replicate": "^1.3.0" + } + }, + "node_modules/@supabase/auth-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/auth-js/-/auth-js-2.76.1.tgz", + "integrity": "sha512-bxmcgPuyjTUBg7+jAohJ15TDh3ph4hXcv7QkRsQgnIpszurD5LYaJPzX638ETQ8zDL4fvHZRHfGrcmHV8C91jA==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "tslib": "2.8.1" + } + }, + "node_modules/@supabase/functions-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/functions-js/-/functions-js-2.76.1.tgz", + "integrity": "sha512-+zJym/GC1sofm5QYKGxHSszCpMW4Ao2dj/WC3YlffAGuIlIhUtWTJvKsv5q7sWaSKUKdDhGpWhZ2OD++fW5BtQ==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "tslib": "2.8.1" + } + }, + "node_modules/@supabase/node-fetch": { + "version": "2.6.15", + "resolved": "https://registry.npmmirror.com/@supabase/node-fetch/-/node-fetch-2.6.15.tgz", + "integrity": "sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/@supabase/postgrest-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/postgrest-js/-/postgrest-js-2.76.1.tgz", + "integrity": "sha512-QJ1Cwim6L9gzWKP8U4Lgw9x/4lMWkZSVMDRYFCH+vVGitVbtfU885swTiioOjjUe4EYGZm+Xktg90twzSVv6IA==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "tslib": "2.8.1" + } + }, + "node_modules/@supabase/realtime-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/realtime-js/-/realtime-js-2.76.1.tgz", + "integrity": "sha512-B5Lfmprea2fx2FS7obp4uAWiRUlEa6j9J3+BvvETGp/2LdkSRBaLEJCBylfcZTXk67ajNPX6ppvKvAZsckqXYg==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "@types/phoenix": "^1.6.6", + "@types/ws": "^8.18.1", + "tslib": "2.8.1", + "ws": "^8.18.2" + } + }, + "node_modules/@supabase/storage-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/storage-js/-/storage-js-2.76.1.tgz", + "integrity": "sha512-OJiNT8tocI9tcTjTjv1SBVLabzgEnS1NorZuqivkiJ0gTYmeg2c2PFmqCARhoQ4whF6zR9MVsX/Mtj2oSv4i/w==", + "license": "MIT", + "dependencies": { + "@supabase/node-fetch": "2.6.15", + "tslib": "2.8.1" + } + }, + "node_modules/@supabase/supabase-js": { + "version": "2.76.1", + "resolved": "https://registry.npmmirror.com/@supabase/supabase-js/-/supabase-js-2.76.1.tgz", + "integrity": "sha512-dYMh9EsTVXZ6WbQ0QmMGIhbXct5+x636tXXaaxUmwjj3kY1jyBTQU8QehxAIfjyRu1mWGV07hoYmTYakkxdSGQ==", + "license": "MIT", + "dependencies": { + "@supabase/auth-js": "2.76.1", + "@supabase/functions-js": "2.76.1", + "@supabase/node-fetch": "2.6.15", + "@supabase/postgrest-js": "2.76.1", + "@supabase/realtime-js": "2.76.1", + "@supabase/storage-js": "2.76.1" + } + }, + "node_modules/@types/node": { + "version": "24.9.1", + "resolved": "https://registry.npmmirror.com/@types/node/-/node-24.9.1.tgz", + "integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==", + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/phoenix": { + "version": "1.6.6", + "resolved": "https://registry.npmmirror.com/@types/phoenix/-/phoenix-1.6.6.tgz", + "integrity": "sha512-PIzZZlEppgrpoT2QgbnDU+MMzuR6BbCjllj0bM70lWoejMeNJAxCchxnv7J3XFkI8MpygtRpzXrIlmWUBclP5A==", + "license": "MIT" + }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmmirror.com/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "optional": true, + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.12.2", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.12.2.tgz", + "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "optional": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/body-parser": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/body-parser/-/body-parser-2.2.0.tgz", + "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.0", + "http-errors": "^2.0.0", + "iconv-lite": "^0.6.3", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.0", + "type-is": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmmirror.com/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmmirror.com/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmmirror.com/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmmirror.com/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "license": "MIT" + }, + "node_modules/content-disposition": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/content-disposition/-/content-disposition-1.0.0.tgz", + "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmmirror.com/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmmirror.com/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmmirror.com/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmmirror.com/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dotenv": { + "version": "17.2.3", + "resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-17.2.3.tgz", + "integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmmirror.com/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmmirror.com/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/express": { + "version": "5.1.0", + "resolved": "https://registry.npmmirror.com/express/-/express-5.1.0.tgz", + "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.0", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmmirror.com/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/finalhandler/-/finalhandler-2.1.0.tgz", + "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.4", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause", + "optional": true + }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "license": "ISC" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmmirror.com/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmmirror.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmmirror.com/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/nodemon": { + "version": "3.1.10", + "resolved": "https://registry.npmmirror.com/nodemon/-/nodemon-3.1.10.tgz", + "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^3.1.2", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmmirror.com/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmmirror.com/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmmirror.com/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmmirror.com/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmmirror.com/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmmirror.com/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmmirror.com/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmmirror.com/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/raw-body/-/raw-body-3.0.1.tgz", + "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", + "license": "MIT", + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.7.0", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/raw-body/node_modules/iconv-lite": { + "version": "0.7.0", + "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.7.0.tgz", + "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmmirror.com/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "license": "MIT", + "optional": true, + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/replicate": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/replicate/-/replicate-1.3.0.tgz", + "integrity": "sha512-Mo25Fw7r1aPSMN+/KhJbLJlzdeLVaGtSRLq8aFH0O6q1fM9LDYipJDC0mobPJ40biBhGk8bUEBVsO1otjTbIdA==", + "license": "Apache-2.0", + "engines": { + "git": ">=2.11.0", + "node": ">=18.0.0", + "npm": ">=7.19.0", + "yarn": ">=1.7.0" + }, + "optionalDependencies": { + "readable-stream": ">=4.0.0" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmmirror.com/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmmirror.com/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "optional": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmmirror.com/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmmirror.com/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmmirror.com/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmmirror.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmmirror.com/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..653887a --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "virtual-tryon-backend", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node index.js", + "start-dev": "nodemon index.js", + "test": "echo \"Error: no test specified\" && exit 1", + "vercel-build": "echo \"Building for Vercel\"" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "commonjs", + "dependencies": { + "@supabase/supabase-js": "^2.76.1", + "axios": "^1.12.2", + "cors": "^2.8.5", + "dotenv": "^17.2.3", + "express": "^5.1.0", + "nodemon": "^3.1.10", + "replicate": "^1.3.0" + } +} diff --git a/vercel.json b/vercel.json new file mode 100644 index 0000000..cb67c1a --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "builds": [ + { + "src": "index.js", + "use": "@vercel/node" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "index.js" + } + ] +} \ No newline at end of file