Skip to content

Instantly share code, notes, and snippets.

@ezirmusitua
Last active September 10, 2019 21:41
Show Gist options
  • Save ezirmusitua/d73b5f14929b6dd01935e74017d1ff87 to your computer and use it in GitHub Desktop.
Save ezirmusitua/d73b5f14929b6dd01935e74017d1ff87 to your computer and use it in GitHub Desktop.
[Nestjs(fastify) serve image] Image serve using nestjs with fastify adapter #node #nestjs #fastify
import {
Controller,
Get,
Response
} from '@nestjs/common';
import {ImageService} from './image.service';
export class GalleryController {
constructor(private readonly imageService: ImageService) {
}
@Get('/thumbnail')
thumbnail(@Response() res) {
try {
const {content, type} = this.ImageService.readImage();
return res.type(type).send(content);
} catch (e) {
console.error(e);
throw new HttpException('Not Found', HttpStatus.NOT_FOUND);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment