Last active
September 10, 2019 21:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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