Files
miaojingAI/scripts/test-custom-img2img-reference-url.mjs

31 lines
908 B
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
const routeSource = fs.readFileSync('src/app/api/generate/image/route.ts', 'utf8');
assert.match(
routeSource,
/generateObjectReadUrl\(fileKey,\s*3600\)/,
'img2img uploaded reference images should expose object signed URLs to upstream providers',
);
assert.match(
routeSource,
/toAbsolutePublicUrl\(publicUrl\)/,
'img2img fallback public URLs should be absolute when object signed URLs are unavailable',
);
assert.match(
routeSource,
/localStorage\.getKeyFromPublicUrl\(image\)/,
'img2img should detect stored /api/local-storage reference images before fetching over HTTP',
);
assert.match(
routeSource,
/localStorage\.readFileAsync\(storedReferenceKey\)/,
'img2img should read stored reference images through the storage adapter for FormData uploads',
);
console.log('custom img2img reference URL policy ok');