Created
November 16, 2018 11:48
-
-
Save hypeofpipe/08b612c1f1f3f366dfffeca1aba88766 to your computer and use it in GitHub Desktop.
This file contains 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 { 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 | |
} | |
} |
This file contains 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 { Module } from '@nestjs/common' | |
import { SampleController } from './app.controller'; | |
@Module({ | |
controllers: [SampleController], | |
providers: [] | |
}) | |
export class AppModule {} |
This file contains 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 { 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