- добавлен shared config presets, custom transforms и allowlist hosts - реализованы Backend endpoints для assets, presets и variants - добавлена orchestration через PostgreSQL, RabbitMQ, S3 и worker - обновлён Gateway read-through flow с L1 cache и корректным Vary: Accept - добавлена миграция resize_mode для variants lookup - обновлены dev scripts, env template, lockfile и документация
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { Controller, Get } from "@nestjs/common"
|
|
import { ApiOkResponse, ApiOperation, ApiTags } from "@nestjs/swagger"
|
|
import {
|
|
CUSTOM_TRANSFORM_CONFIG,
|
|
IMAGE_PRESETS,
|
|
loadAllowedSourceHostsFromEnv,
|
|
parseBooleanFlag,
|
|
type ImagePreset,
|
|
} from "@image-platform/image-config"
|
|
|
|
import { PresetsResponseDto } from "./presets.dto"
|
|
|
|
@ApiTags("presets")
|
|
@Controller("presets")
|
|
export class PresetsController {
|
|
@Get()
|
|
@ApiOperation({
|
|
summary: "получить доступные presets и custom config",
|
|
description: "Возвращает статический config presets, custom transform limits и mock allowlist source hosts.",
|
|
})
|
|
@ApiOkResponse({ description: "Конфигурация presets возвращена.", type: PresetsResponseDto })
|
|
getPresets(): PresetsResponseDto {
|
|
return {
|
|
allowedSourceHosts: [...loadAllowedSourceHostsFromEnv()],
|
|
custom: {
|
|
enabled: parseBooleanFlag(process.env.IMAGE_ALLOW_CUSTOM_TRANSFORMS, false),
|
|
formats: CUSTOM_TRANSFORM_CONFIG.formats,
|
|
maxHeight: CUSTOM_TRANSFORM_CONFIG.maxHeight,
|
|
maxWidth: CUSTOM_TRANSFORM_CONFIG.maxWidth,
|
|
quality: CUSTOM_TRANSFORM_CONFIG.quality,
|
|
},
|
|
presets: Object.entries(IMAGE_PRESETS).map(([name, preset]) => {
|
|
const config: ImagePreset = preset
|
|
|
|
return {
|
|
formats: config.formats,
|
|
height: config.height,
|
|
mode: config.mode,
|
|
name,
|
|
qualities: config.qualities,
|
|
quality: config.quality,
|
|
resize: config.resize,
|
|
width: config.width,
|
|
widths: config.widths,
|
|
}
|
|
}),
|
|
}
|
|
}
|
|
}
|