feat: добавить базовые сервисы image-platform

- добавлены backend, admin, gateway и worker skeleton
- добавлены Drizzle schema, database package и initial migration
- добавлены shared packages для RabbitMQ topology и S3 helpers
- обновлены dev-инфраструктура, env example, scripts и dependencies
- обновлена документация под versioned image URLs и read-through flow
This commit is contained in:
2026-05-05 09:59:21 +03:00
parent 37592c8b81
commit bcadb85a83
66 changed files with 8698 additions and 213 deletions

View File

@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}

27
apps/backend/package.json Normal file
View File

@@ -0,0 +1,27 @@
{
"name": "@image-platform/backend",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "nest build",
"dev": "nest start --watch",
"start": "node dist/main.js",
"typecheck": "tsc --noEmit -p tsconfig.json"
},
"dependencies": {
"@nestjs/common": "^11.0.0",
"@nestjs/core": "^11.0.0",
"@nestjs/platform-express": "^11.0.0",
"@nestjs/swagger": "^11.0.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.1"
},
"devDependencies": {
"@nestjs/cli": "^11.0.0",
"@nestjs/schematics": "^11.0.0",
"@types/node": "^24.0.0",
"@types/swagger-ui-express": "^4.1.8",
"typescript": "^5.9.0"
}
}

View File

@@ -0,0 +1,9 @@
import { Module } from "@nestjs/common"
import { HealthController } from "./health/health.controller"
import { InternalImagesController } from "./internal-images/internal-images.controller"
@Module({
controllers: [HealthController, InternalImagesController],
})
export class AppModule {}

View File

@@ -0,0 +1,9 @@
import { ApiProperty } from "@nestjs/swagger"
export class HealthResponseDto {
@ApiProperty({ example: "image-platform-api" })
service!: string
@ApiProperty({ example: "ok" })
status!: string
}

View File

@@ -0,0 +1,18 @@
import { Controller, Get } from "@nestjs/common"
import { ApiOkResponse, ApiOperation, ApiTags } from "@nestjs/swagger"
import { HealthResponseDto } from "./health-response.dto"
@ApiTags("system")
@Controller("health")
export class HealthController {
@Get()
@ApiOperation({ summary: "Проверить состояние API" })
@ApiOkResponse({ type: HealthResponseDto })
getHealth(): HealthResponseDto {
return {
service: "image-platform-api",
status: "ok",
}
}
}

View File

@@ -0,0 +1,21 @@
import { ApiProperty } from "@nestjs/swagger"
export class EnsureImageVariantRequestDto {
@ApiProperty({ example: "asset_123" })
assetId!: string
@ApiProperty({ example: 4, minimum: 1 })
version!: number
@ApiProperty({ example: "card" })
preset!: string
@ApiProperty({ example: 640, minimum: 1 })
width!: number
@ApiProperty({ example: 80, minimum: 1 })
quality!: number
@ApiProperty({ enum: ["auto", "avif", "webp", "jpg", "png"], example: "auto" })
format!: "auto" | "avif" | "jpg" | "png" | "webp"
}

View File

@@ -0,0 +1,19 @@
import { Body, Controller, NotImplementedException, Post } from "@nestjs/common"
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"
import { EnsureImageVariantRequestDto } from "./ensure-image-variant.dto"
@ApiTags("internal-images")
@Controller("internal/images")
export class InternalImagesController {
@Post("ensure")
@ApiOperation({ summary: "Ensure image variant for Gateway L1 miss" })
@ApiResponse({ status: 501, description: "Read-through image pipeline is not implemented yet" })
ensureImageVariant(@Body() request: EnsureImageVariantRequestDto): never {
throw new NotImplementedException({
message: "image read-through pipeline is not implemented yet",
request,
status: "not_implemented",
})
}
}

37
apps/backend/src/main.ts Normal file
View File

@@ -0,0 +1,37 @@
import { NestFactory } from "@nestjs/core"
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"
import { AppModule } from "./app.module"
async function bootstrap() {
const app = await NestFactory.create(AppModule)
app.setGlobalPrefix("api")
app.enableShutdownHooks()
const openApiConfig = new DocumentBuilder()
.setTitle("Image Platform API")
.setDescription("Control plane for image assets, variants, S3 storage and external imgproxy.")
.setVersion("0.1.0")
.addTag("system")
.addTag("assets")
.addTag("variants")
.addTag("allowed-hosts")
.addTag("internal-images")
.build()
const openApiDocument = SwaggerModule.createDocument(app, openApiConfig)
SwaggerModule.setup("docs", app, openApiDocument, {
jsonDocumentUrl: "docs-json",
swaggerOptions: {
persistAuthorization: true,
},
})
const port = Number.parseInt(process.env.API_PORT ?? "3001", 10)
await app.listen(port)
}
void bootstrap()

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"noEmit": false
},
"exclude": ["node_modules", "dist", "test", "**/*.spec.ts"]
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"incremental": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist",
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictPropertyInitialization": false,
"target": "ES2023",
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}