forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: generalise interfaces, improve decorators
- Loading branch information
1 parent
11b397a
commit 84f531c
Showing
25 changed files
with
68 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
src/common/interfaces/exceptions/exception-filter.interface.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface ExceptionFilter { | ||
catch(exception, response); | ||
export interface ExceptionFilter<T = any, R = any> { | ||
catch(exception: T, response: R); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/common/interfaces/exceptions/rpc-exception-filter.interface.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Observable } from 'rxjs/Observable'; | ||
|
||
export interface RpcExceptionFilter { | ||
catch(exception): Observable<any>; | ||
export interface RpcExceptionFilter<T = any, R = any> { | ||
catch(exception: T): Observable<R>; | ||
} |
4 changes: 2 additions & 2 deletions
4
src/common/interfaces/exceptions/ws-exception-filter.interface.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface WsExceptionFilter { | ||
catch(exception, client); | ||
export interface WsExceptionFilter<T = any, R = any> { | ||
catch(exception: T, client: R); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { Observable } from 'rxjs/Observable'; | ||
import { ExecutionContext } from './execution-context.interface'; | ||
|
||
export interface NestInterceptor { | ||
export interface NestInterceptor<T = any, R = any> { | ||
intercept( | ||
dataOrRequest, | ||
context: ExecutionContext, | ||
stream$: Observable<any>, | ||
): Observable<any> | Promise<Observable<any>>; | ||
stream$: Observable<T>, | ||
): Observable<R> | Promise<Observable<R>>; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Paramtype } from './paramtype.interface'; | ||
|
||
export type Transform<T> = (value: T, metadata: ArgumentMetadata) => any; | ||
export type Transform<T = any> = (value: T, metadata: ArgumentMetadata) => any; | ||
|
||
export interface ArgumentMetadata { | ||
type: Paramtype; | ||
metatype?: new (...args) => any; | ||
data?: string; | ||
} | ||
|
||
export interface PipeTransform<T> { | ||
transform(value: T, metadata: ArgumentMetadata): any; | ||
export interface PipeTransform<T = any, R = any> { | ||
transform(value: T, metadata: ArgumentMetadata): R; | ||
} |
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
4 changes: 2 additions & 2 deletions
4
src/common/interfaces/websockets/web-socket-adapter.interface.ts
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function extendArrayMetadata<T extends Array<any>>( | ||
key: string, | ||
metadata: T, | ||
target, | ||
) { | ||
const previousValue = Reflect.getMetadata(key, target) || []; | ||
const value = [...previousValue, ...metadata]; | ||
Reflect.defineMetadata(key, value, target); | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface OnGatewayConnection { | ||
handleConnection(client: any); | ||
export interface OnGatewayConnection<T = any> { | ||
handleConnection(client: T); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface OnGatewayDisconnect { | ||
handleDisconnect(client: any); | ||
export interface OnGatewayDisconnect<T = any> { | ||
handleDisconnect(client: T); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export interface OnGatewayInit { | ||
afterInit(server: any); | ||
export interface OnGatewayInit<T = any> { | ||
afterInit(server: T); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export interface WsResponse<T> { | ||
export interface WsResponse<T = any> { | ||
event: string; | ||
data: T; | ||
} |
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
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