Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
504 additions
and
168 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import { expect } from 'chai'; | ||
import * as io from 'socket.io-client'; | ||
import { ErrorGateway } from '../src/error.gateway'; | ||
|
||
describe('ErrorGateway', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const testingModule = await Test.createTestingModule({ | ||
providers: [ErrorGateway], | ||
}).compile(); | ||
app = await testingModule.createNestApplication(); | ||
await app.listenAsync(3000); | ||
}); | ||
|
||
it(`should handle error`, async () => { | ||
const ws = io.connect('http://localhost:8080'); | ||
ws.emit('push', { | ||
test: 'test', | ||
}); | ||
await new Promise(resolve => | ||
ws.on('exception', data => { | ||
expect(data).to.be.eql({ | ||
status: 'error', | ||
message: 'test', | ||
}); | ||
resolve(); | ||
}), | ||
); | ||
}); | ||
|
||
afterEach(() => app.close()); | ||
}); |
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,14 @@ | ||
import { | ||
SubscribeMessage, | ||
WebSocketGateway, | ||
WsException, | ||
} from '@nestjs/websockets'; | ||
import { throwError } from 'rxjs'; | ||
|
||
@WebSocketGateway(8080) | ||
export class ErrorGateway { | ||
@SubscribeMessage('push') | ||
onPush(client, data) { | ||
return throwError(new WsException('test')); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "5.4.1" | ||
"version": "5.5.0" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const AXIOS_INSTANCE_TOKEN = 'AXIOS_INSTANCE_TOKEN'; | ||
export const HTTP_MODULE_ID = 'HTTP_MODULE_ID'; | ||
export const HTTP_MODULE_OPTIONS = 'HTTP_MODULE_OPTIONS'; |
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,2 +1,3 @@ | ||
export * from './http.module'; | ||
export * from './http.service'; | ||
export * from './interfaces'; |
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,19 @@ | ||
import { AxiosRequestConfig } from 'axios'; | ||
import { ModuleMetadata, Provider, Type } from '../../interfaces'; | ||
|
||
export interface HttpModuleOptions extends AxiosRequestConfig {} | ||
|
||
export interface HttpModuleOptionsFactory { | ||
createHttpOptions(): Promise<HttpModuleOptions> | HttpModuleOptions; | ||
} | ||
|
||
export interface HttpModuleAsyncOptions | ||
extends Pick<ModuleMetadata, 'imports'> { | ||
useExisting?: Type<HttpModuleOptions>; | ||
useClass?: Type<HttpModuleOptions>; | ||
useFactory?: ( | ||
...args: any[] | ||
) => Promise<HttpModuleOptions> | HttpModuleOptions; | ||
inject?: any[]; | ||
extraProviders?: Provider[]; | ||
} |
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 @@ | ||
export * from './http-module.interface'; |
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
28 changes: 28 additions & 0 deletions
28
packages/common/interfaces/external/validation-error.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Validation error description. | ||
* @see https://github.com/typestack/class-validator | ||
*/ | ||
export interface ValidationError { | ||
/** | ||
* Object that was validated. | ||
*/ | ||
target: Object; | ||
/** | ||
* Object's property that haven't pass validation. | ||
*/ | ||
property: string; | ||
/** | ||
* Value that haven't pass a validation. | ||
*/ | ||
value: any; | ||
/** | ||
* Constraints that failed validation with error messages. | ||
*/ | ||
constraints: { | ||
[type: string]: string; | ||
}; | ||
/** | ||
* Contains all nested validation errors of the property. | ||
*/ | ||
children: ValidationError[]; | ||
} |
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
Oops, something went wrong.