Rate limits use X-Forwarded-For behind prod nginx; hotlink security headers are set on /i/ in nginx only.
16 lines
608 B
TypeScript
16 lines
608 B
TypeScript
import { Controller, Get, Param, StreamableFile } from '@nestjs/common';
|
|
import { HotlinkImageParamsDto } from '../dto/HotlinkImageParamsDto';
|
|
import { UploadService } from '../services/UploadService';
|
|
|
|
@Controller('i')
|
|
export class HotlinkImageController {
|
|
constructor(private readonly uploadService: UploadService) {}
|
|
|
|
@Get(':id/:secret')
|
|
async getImage(@Param() params: HotlinkImageParamsDto): Promise<StreamableFile> {
|
|
const { body, mimeType } = await this.uploadService.getHotlinkImage(params.id, params.secret);
|
|
|
|
return new StreamableFile(body, { type: mimeType });
|
|
}
|
|
}
|