v2: модульный монолит — очередь, персистентность, безопасность, SSE, тесты
Some checks failed
test / test (push) Failing after 24s
Some checks failed
test / test (push) Failing after 24s
Реализация целевого дизайна (docs/architecture/target-design.md): - src/: модульная структура (config, logger, errors, http, core: auth/history/jobs/engines/comfy/codex/images) - Очередь заданий: FIFO, кониурентность codex=1 / comfy-upscale=2, MAX_QUEUED_JOBS=5, JSONL-журнал и восстановление после рестарта (running → interrupted, upscale requeue) - Персистентные сессии (sha256-хеши токенов), scrypt-хеш пароля, rate-limit входа, Origin-проверка, magic-byte валидация аплоадов - Атомарная запись манифеста истории, каскадное удаление, URL с фактическим расширением + 302-алиас /image.jpg, миграция history/ → data/history - Даунскейл sharp до 1024px перед Codex + масштабирование области референса - SSE /api/events с фолбэком на polling, фронтенд переведён на ES-модули (public/js/) - Тесты node:test + supertest (27), CI workflow test.yml, Docker/деплой: том kadr-data - Документация: README, docs/architecture/
This commit is contained in:
75
src/core/comfy/workflows.js
Normal file
75
src/core/comfy/workflows.js
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
function imageScaleNode(imageSource, size) {
|
||||
return {
|
||||
class_type: "ImageScale",
|
||||
inputs: {
|
||||
image: imageSource,
|
||||
upscale_method: "lanczos",
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
crop: "disabled",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildUpscaleWorkflow(uploaded, modelName, scaledSize) {
|
||||
const imageSource = scaledSize ? ["2", 0] : ["1", 0];
|
||||
|
||||
const workflow = {
|
||||
"1": {
|
||||
class_type: "LoadImage",
|
||||
inputs: {
|
||||
image: uploaded.loadImageName,
|
||||
},
|
||||
},
|
||||
"3": {
|
||||
class_type: "UpscaleModelLoader",
|
||||
inputs: {
|
||||
model_name: modelName,
|
||||
},
|
||||
},
|
||||
"4": {
|
||||
class_type: "ImageUpscaleWithModel",
|
||||
inputs: {
|
||||
upscale_model: ["3", 0],
|
||||
image: imageSource,
|
||||
},
|
||||
},
|
||||
"5": {
|
||||
class_type: "SaveImage",
|
||||
inputs: {
|
||||
images: ["4", 0],
|
||||
filename_prefix: "prompt_editor/upscale",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (scaledSize) {
|
||||
workflow["2"] = imageScaleNode(["1", 0], scaledSize);
|
||||
}
|
||||
|
||||
return {
|
||||
workflow,
|
||||
saveNodeId: "5",
|
||||
};
|
||||
}
|
||||
|
||||
function makePublicResult(image) {
|
||||
const parameters = new URLSearchParams({
|
||||
filename: image.filename,
|
||||
subfolder: image.subfolder || "",
|
||||
type: image.type || "output",
|
||||
});
|
||||
|
||||
return {
|
||||
...image,
|
||||
url: `/api/result?${parameters.toString()}`,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
imageScaleNode,
|
||||
buildUpscaleWorkflow,
|
||||
makePublicResult,
|
||||
};
|
||||
Reference in New Issue
Block a user