Skip to content

Instantly share code, notes, and snippets.

@hypeofpipe
Created November 16, 2018 11:48
Show Gist options
  • Save hypeofpipe/08b612c1f1f3f366dfffeca1aba88766 to your computer and use it in GitHub Desktop.
Save hypeofpipe/08b612c1f1f3f366dfffeca1aba88766 to your computer and use it in GitHub Desktop.
import { Get, Controller, Post, Body, UsePipes, UseInterceptors, FileInterceptor, UploadedFile } from '@nestjs/common'
import { SamplePipe } from './sample.pipe';
@Controller('sample')
export class SampleController {
@Get()
sampleGet() {
return 'hello'
}
@UsePipes(SamplePipe)
@UseInterceptors(FileInterceptor('file'))
@Post()
samplePost(@UploadedFile() file) {
return file
}
}
import { Module } from '@nestjs/common'
import { SampleController } from './app.controller';
@Module({
controllers: [SampleController],
providers: []
})
export class AppModule {}
import { Injectable, ArgumentMetadata, PipeTransform } from '@nestjs/common';
@Injectable()
export class SamplePipe implements PipeTransform {
transform(value: any, metadata: ArgumentMetadata) {
console.log("I'm working")
return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment