mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
style: fix formatting
This commit is contained in:
@@ -6,7 +6,7 @@ export class AppController {
|
|||||||
@Sse('sse')
|
@Sse('sse')
|
||||||
sse(): Observable<MessageEvent> {
|
sse(): Observable<MessageEvent> {
|
||||||
return interval(1000).pipe(
|
return interval(1000).pipe(
|
||||||
map(_ => ({ data: { hello: 'world' } } as MessageEvent)),
|
map(_ => ({ data: { hello: 'world' } }) as MessageEvent),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ export interface ConfigurableModuleBuilderOptions {
|
|||||||
export class ConfigurableModuleBuilder<
|
export class ConfigurableModuleBuilder<
|
||||||
ModuleOptions,
|
ModuleOptions,
|
||||||
StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY,
|
StaticMethodKey extends string = typeof DEFAULT_METHOD_KEY,
|
||||||
FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
FactoryClassMethodKey extends
|
||||||
|
string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
||||||
ExtraModuleDefinitionOptions = {},
|
ExtraModuleDefinitionOptions = {},
|
||||||
> {
|
> {
|
||||||
protected staticMethodKey: StaticMethodKey;
|
protected staticMethodKey: StaticMethodKey;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ export type ConfigurableModuleOptionsFactory<
|
|||||||
*/
|
*/
|
||||||
export interface ConfigurableModuleAsyncOptions<
|
export interface ConfigurableModuleAsyncOptions<
|
||||||
ModuleOptions,
|
ModuleOptions,
|
||||||
FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
FactoryClassMethodKey extends
|
||||||
|
string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
||||||
> extends Pick<ModuleMetadata, 'imports'> {
|
> extends Pick<ModuleMetadata, 'imports'> {
|
||||||
/**
|
/**
|
||||||
* Injection token resolving to an existing provider. The provider must implement
|
* Injection token resolving to an existing provider. The provider must implement
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import { ConfigurableModuleAsyncOptions } from './configurable-module-async-opti
|
|||||||
export type ConfigurableModuleCls<
|
export type ConfigurableModuleCls<
|
||||||
ModuleOptions,
|
ModuleOptions,
|
||||||
MethodKey extends string = typeof DEFAULT_METHOD_KEY,
|
MethodKey extends string = typeof DEFAULT_METHOD_KEY,
|
||||||
FactoryClassMethodKey extends string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
FactoryClassMethodKey extends
|
||||||
|
string = typeof DEFAULT_FACTORY_CLASS_METHOD_KEY,
|
||||||
ExtraModuleDefinitionOptions = {},
|
ExtraModuleDefinitionOptions = {},
|
||||||
> = {
|
> = {
|
||||||
new (): any;
|
new (): any;
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ export abstract class FileValidator<
|
|||||||
* Indicates if this file should be considered valid, according to the options passed in the constructor.
|
* Indicates if this file should be considered valid, according to the options passed in the constructor.
|
||||||
* @param file the file from the request object
|
* @param file the file from the request object
|
||||||
*/
|
*/
|
||||||
abstract isValid(file?: TFile | TFile[] | Record<string, TFile[]>): boolean | Promise<boolean>;
|
abstract isValid(
|
||||||
|
file?: TFile | TFile[] | Record<string, TFile[]>,
|
||||||
|
): boolean | Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds an error message in case the validation fails.
|
* Builds an error message in case the validation fails.
|
||||||
|
|||||||
@@ -83,9 +83,8 @@ export class NestContainer {
|
|||||||
if (!metatype) {
|
if (!metatype) {
|
||||||
throw new UndefinedForwardRefException(scope);
|
throw new UndefinedForwardRefException(scope);
|
||||||
}
|
}
|
||||||
const { type, dynamicMetadata, token } = await this.moduleCompiler.compile(
|
const { type, dynamicMetadata, token } =
|
||||||
metatype,
|
await this.moduleCompiler.compile(metatype);
|
||||||
);
|
|
||||||
if (this.modules.has(token)) {
|
if (this.modules.has(token)) {
|
||||||
return {
|
return {
|
||||||
moduleRef: this.modules.get(token),
|
moduleRef: this.modules.get(token),
|
||||||
@@ -124,9 +123,8 @@ export class NestContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { token } = await this.moduleCompiler.compile(metatypeToReplace);
|
const { token } = await this.moduleCompiler.compile(metatypeToReplace);
|
||||||
const { type, dynamicMetadata } = await this.moduleCompiler.compile(
|
const { type, dynamicMetadata } =
|
||||||
newMetatype,
|
await this.moduleCompiler.compile(newMetatype);
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
moduleRef: await this.setModule(
|
moduleRef: await this.setModule(
|
||||||
@@ -220,9 +218,8 @@ export class NestContainer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const moduleRef = this.modules.get(token);
|
const moduleRef = this.modules.get(token);
|
||||||
const { token: relatedModuleToken } = await this.moduleCompiler.compile(
|
const { token: relatedModuleToken } =
|
||||||
relatedModule,
|
await this.moduleCompiler.compile(relatedModule);
|
||||||
);
|
|
||||||
const related = this.modules.get(relatedModuleToken);
|
const related = this.modules.get(relatedModuleToken);
|
||||||
moduleRef.addImport(related);
|
moduleRef.addImport(related);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ import { RouteInfoPathExtractor } from './route-info-path-extractor';
|
|||||||
import { RoutesMapper } from './routes-mapper';
|
import { RoutesMapper } from './routes-mapper';
|
||||||
|
|
||||||
export class MiddlewareModule<
|
export class MiddlewareModule<
|
||||||
TAppOptions extends NestApplicationContextOptions = NestApplicationContextOptions,
|
TAppOptions extends
|
||||||
|
NestApplicationContextOptions = NestApplicationContextOptions,
|
||||||
> {
|
> {
|
||||||
private readonly routerProxy = new RouterProxy();
|
private readonly routerProxy = new RouterProxy();
|
||||||
private readonly exceptionFiltersCache = new WeakMap();
|
private readonly exceptionFiltersCache = new WeakMap();
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ import { Module } from './injector/module';
|
|||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export class NestApplicationContext<
|
export class NestApplicationContext<
|
||||||
TOptions extends NestApplicationContextOptions = NestApplicationContextOptions,
|
TOptions extends
|
||||||
|
NestApplicationContextOptions = NestApplicationContextOptions,
|
||||||
>
|
>
|
||||||
extends AbstractInstanceResolver
|
extends AbstractInstanceResolver
|
||||||
implements INestApplicationContext
|
implements INestApplicationContext
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe('ExternalExceptionFilterContext', () => {
|
|||||||
it('should return plain ExceptionHandler object', () => {
|
it('should return plain ExceptionHandler object', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new EmptyMetadata(),
|
new EmptyMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.be.empty;
|
expect((filter as any).filters).to.be.empty;
|
||||||
@@ -50,7 +50,7 @@ describe('ExternalExceptionFilterContext', () => {
|
|||||||
it('should return ExceptionHandler object with exception filters', () => {
|
it('should return ExceptionHandler object with exception filters', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new WithMetadata(),
|
new WithMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.not.be.empty;
|
expect((filter as any).filters).to.not.be.empty;
|
||||||
@@ -105,7 +105,7 @@ describe('ExternalExceptionFilterContext', () => {
|
|||||||
.callsFake(() => scopedFilterWrappers);
|
.callsFake(() => scopedFilterWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
||||||
instance,
|
instance,
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ describe('GuardsContextCreator', () => {
|
|||||||
.callsFake(() => scopedGuardWrappers);
|
.callsFake(() => scopedGuardWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(guardsContextCreator.getGlobalMetadata({ id: 3 })).to.contains(
|
expect(guardsContextCreator.getGlobalMetadata({ id: 3 })).to.contains(
|
||||||
instance,
|
instance,
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ describe('Injector', () => {
|
|||||||
class MainTest {
|
class MainTest {
|
||||||
@Inject() property: DependencyOne;
|
@Inject() property: DependencyOne;
|
||||||
|
|
||||||
constructor(public one: DependencyOne, public two: DependencyTwo) {}
|
constructor(
|
||||||
|
public one: DependencyOne,
|
||||||
|
public two: DependencyTwo,
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let moduleDeps: Module;
|
let moduleDeps: Module;
|
||||||
@@ -743,7 +746,7 @@ describe('Injector', () => {
|
|||||||
|
|
||||||
const loadInstanceStub = sinon
|
const loadInstanceStub = sinon
|
||||||
.stub(injector, 'loadInstance')
|
.stub(injector, 'loadInstance')
|
||||||
.callsFake(async () => ({} as any));
|
.callsFake(async () => ({}) as any);
|
||||||
|
|
||||||
await injector.loadEnhancersPerContext(wrapper, STATIC_CONTEXT);
|
await injector.loadEnhancersPerContext(wrapper, STATIC_CONTEXT);
|
||||||
expect(loadInstanceStub.calledTwice).to.be.true;
|
expect(loadInstanceStub.calledTwice).to.be.true;
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ describe('InterceptorsContextCreator', () => {
|
|||||||
.callsFake(() => scopedInterceptorWrappers);
|
.callsFake(() => scopedInterceptorWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
interceptorsContextCreator.getGlobalMetadata({ id: 3 }),
|
interceptorsContextCreator.getGlobalMetadata({ id: 3 }),
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ describe('PipesContextCreator', () => {
|
|||||||
.callsFake(() => scopedPipeWrappers);
|
.callsFake(() => scopedPipeWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(creator.getGlobalMetadata({ id: 3 })).to.contains(
|
expect(creator.getGlobalMetadata({ id: 3 })).to.contains(
|
||||||
instance,
|
instance,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ describe('RouterExceptionFilters', () => {
|
|||||||
it('should return plain ExceptionHandler object', () => {
|
it('should return plain ExceptionHandler object', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new EmptyMetadata(),
|
new EmptyMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.be.empty;
|
expect((filter as any).filters).to.be.empty;
|
||||||
@@ -48,7 +48,7 @@ describe('RouterExceptionFilters', () => {
|
|||||||
it('should return ExceptionHandler object with exception filters', () => {
|
it('should return ExceptionHandler object with exception filters', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new WithMetadata(),
|
new WithMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.not.be.empty;
|
expect((filter as any).filters).to.not.be.empty;
|
||||||
@@ -97,7 +97,7 @@ describe('RouterExceptionFilters', () => {
|
|||||||
.callsFake(() => scopedFilterWrappers);
|
.callsFake(() => scopedFilterWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
||||||
instance,
|
instance,
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ describe('RouterExplorer', () => {
|
|||||||
() =>
|
() =>
|
||||||
({
|
({
|
||||||
next: nextSpy,
|
next: nextSpy,
|
||||||
} as any),
|
}) as any,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import { Observable } from 'rxjs';
|
|||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export interface MessageHandler<TInput = any, TContext = any, TResult = any> {
|
export interface MessageHandler<TInput = any, TContext = any, TResult = any> {
|
||||||
(data: TInput, ctx?: TContext):
|
(
|
||||||
| Promise<Observable<TResult>>
|
data: TInput,
|
||||||
| Promise<TResult>;
|
ctx?: TContext,
|
||||||
|
): Promise<Observable<TResult>> | Promise<TResult>;
|
||||||
next?: (
|
next?: (
|
||||||
data: TInput,
|
data: TInput,
|
||||||
ctx?: TContext,
|
ctx?: TContext,
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ import { ListenersController } from './listeners-controller';
|
|||||||
import { Server } from './server/server';
|
import { Server } from './server/server';
|
||||||
|
|
||||||
export class MicroservicesModule<
|
export class MicroservicesModule<
|
||||||
TAppOptions extends NestApplicationContextOptions = NestApplicationContextOptions,
|
TAppOptions extends
|
||||||
|
NestApplicationContextOptions = NestApplicationContextOptions,
|
||||||
> {
|
> {
|
||||||
private readonly clientsContainer = new ClientsContainer();
|
private readonly clientsContainer = new ClientsContainer();
|
||||||
private listenersController: ListenersController;
|
private listenersController: ListenersController;
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ export interface RmqRecordOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class RmqRecord<TData = any> {
|
export class RmqRecord<TData = any> {
|
||||||
constructor(public readonly data: TData, public options?: RmqRecordOptions) {}
|
constructor(
|
||||||
|
public readonly data: TData,
|
||||||
|
public options?: RmqRecordOptions,
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class RmqRecordBuilder<TData> {
|
export class RmqRecordBuilder<TData> {
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ describe('ClientMqtt', () => {
|
|||||||
({
|
({
|
||||||
addListener: () => ({}),
|
addListener: () => ({}),
|
||||||
removeListener: () => ({}),
|
removeListener: () => ({}),
|
||||||
} as any),
|
}) as any,
|
||||||
);
|
);
|
||||||
handleErrorsSpy = sinon.spy(client, 'handleError');
|
handleErrorsSpy = sinon.spy(client, 'handleError');
|
||||||
connect$Stub = sinon.stub(client, 'connect$' as any).callsFake(() => ({
|
connect$Stub = sinon.stub(client, 'connect$' as any).callsFake(() => ({
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ describe('ClientNats', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
createClientSpy = sinon
|
createClientSpy = sinon
|
||||||
.stub(client, 'createClient')
|
.stub(client, 'createClient')
|
||||||
.callsFake(() => ({} as any));
|
.callsFake(() => ({}) as any);
|
||||||
handleStatusUpdatesSpy = sinon.spy(client, 'handleStatusUpdates');
|
handleStatusUpdatesSpy = sinon.spy(client, 'handleStatusUpdates');
|
||||||
|
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ describe('ClientRedis', () => {
|
|||||||
({
|
({
|
||||||
addListener: () => null,
|
addListener: () => null,
|
||||||
removeListener: () => null,
|
removeListener: () => null,
|
||||||
} as any),
|
}) as any,
|
||||||
);
|
);
|
||||||
handleErrorsSpy = sinon.spy(client, 'handleError');
|
handleErrorsSpy = sinon.spy(client, 'handleError');
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ describe('ExceptionFiltersContext', () => {
|
|||||||
it('should return plain ExceptionHandler object', () => {
|
it('should return plain ExceptionHandler object', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new EmptyMetadata(),
|
new EmptyMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.be.empty;
|
expect((filter as any).filters).to.be.empty;
|
||||||
@@ -46,7 +46,7 @@ describe('ExceptionFiltersContext', () => {
|
|||||||
it('should return ExceptionHandler object with exception filters', () => {
|
it('should return ExceptionHandler object with exception filters', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new WithMetadata(),
|
new WithMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.not.be.empty;
|
expect((filter as any).filters).to.not.be.empty;
|
||||||
@@ -76,7 +76,7 @@ describe('ExceptionFiltersContext', () => {
|
|||||||
.callsFake(() => scopedFilterWrappers);
|
.callsFake(() => scopedFilterWrappers);
|
||||||
sinon
|
sinon
|
||||||
.stub(instanceWrapper, 'getInstanceByContextId')
|
.stub(instanceWrapper, 'getInstanceByContextId')
|
||||||
.callsFake(() => ({ instance } as any));
|
.callsFake(() => ({ instance }) as any);
|
||||||
|
|
||||||
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
expect(exceptionFilter.getGlobalMetadata({ id: 3 })).to.contains(
|
||||||
instance,
|
instance,
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ describe('ListenersController', () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
sinon.stub(container, 'getModuleByKey').callsFake(() => ({} as any));
|
sinon.stub(container, 'getModuleByKey').callsFake(() => ({}) as any);
|
||||||
});
|
});
|
||||||
it(`should call "addHandler" method of server for each pattern handler`, () => {
|
it(`should call "addHandler" method of server for each pattern handler`, () => {
|
||||||
explorer.expects('explore').returns(handlers);
|
explorer.expects('explore').returns(handlers);
|
||||||
@@ -203,12 +203,12 @@ describe('ListenersController', () => {
|
|||||||
() =>
|
() =>
|
||||||
({
|
({
|
||||||
handle: handleSpy,
|
handle: handleSpy,
|
||||||
} as any),
|
}) as any,
|
||||||
);
|
);
|
||||||
|
|
||||||
sinon
|
sinon
|
||||||
.stub((instance as any).container, 'registerRequestProvider')
|
.stub((instance as any).container, 'registerRequestProvider')
|
||||||
.callsFake(() => ({} as any));
|
.callsFake(() => ({}) as any);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when "loadPerContext" resolves', () => {
|
describe('when "loadPerContext" resolves', () => {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ describe('ServerKafka', () => {
|
|||||||
it('should call "bindEvents"', async () => {
|
it('should call "bindEvents"', async () => {
|
||||||
bindEventsStub = sinon
|
bindEventsStub = sinon
|
||||||
.stub(server, 'bindEvents')
|
.stub(server, 'bindEvents')
|
||||||
.callsFake(() => ({} as any));
|
.callsFake(() => ({}) as any);
|
||||||
await server.listen(callback);
|
await server.listen(callback);
|
||||||
expect(bindEventsStub.called).to.be.true;
|
expect(bindEventsStub.called).to.be.true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ describe('ServerRedis', () => {
|
|||||||
});
|
});
|
||||||
it('should call "handleEvent" if identifier is not present', async () => {
|
it('should call "handleEvent" if identifier is not present', async () => {
|
||||||
const handleEventSpy = sinon.spy(server, 'handleEvent');
|
const handleEventSpy = sinon.spy(server, 'handleEvent');
|
||||||
sinon.stub(server, 'parseMessage').callsFake(() => ({ data } as any));
|
sinon.stub(server, 'parseMessage').callsFake(() => ({ data }) as any);
|
||||||
|
|
||||||
await server.handleMessage(channel, JSON.stringify({}), null, channel);
|
await server.handleMessage(channel, JSON.stringify({}), null, channel);
|
||||||
expect(handleEventSpy.called).to.be.true;
|
expect(handleEventSpy.called).to.be.true;
|
||||||
});
|
});
|
||||||
it(`should publish NO_MESSAGE_HANDLER if pattern not exists in messageHandlers object`, async () => {
|
it(`should publish NO_MESSAGE_HANDLER if pattern not exists in messageHandlers object`, async () => {
|
||||||
sinon.stub(server, 'parseMessage').callsFake(() => ({ id, data } as any));
|
sinon.stub(server, 'parseMessage').callsFake(() => ({ id, data }) as any);
|
||||||
await server.handleMessage(
|
await server.handleMessage(
|
||||||
channel,
|
channel,
|
||||||
JSON.stringify({ id }),
|
JSON.stringify({ id }),
|
||||||
@@ -160,7 +160,7 @@ describe('ServerRedis', () => {
|
|||||||
(server as any).messageHandlers = objectToMap({
|
(server as any).messageHandlers = objectToMap({
|
||||||
[channel]: handler,
|
[channel]: handler,
|
||||||
});
|
});
|
||||||
sinon.stub(server, 'parseMessage').callsFake(() => ({ id, data } as any));
|
sinon.stub(server, 'parseMessage').callsFake(() => ({ id, data }) as any);
|
||||||
|
|
||||||
await server.handleMessage(channel, {}, null, channel);
|
await server.handleMessage(channel, {}, null, channel);
|
||||||
expect(handler.calledWith(data)).to.be.true;
|
expect(handler.calledWith(data)).to.be.true;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ describe('ServerRMQ', () => {
|
|||||||
createChannelStub = sinon.stub().callsFake(({ setup }) => setup());
|
createChannelStub = sinon.stub().callsFake(({ setup }) => setup());
|
||||||
setupChannelStub = sinon
|
setupChannelStub = sinon
|
||||||
.stub(server, 'setupChannel')
|
.stub(server, 'setupChannel')
|
||||||
.callsFake(() => ({} as any));
|
.callsFake(() => ({}) as any);
|
||||||
|
|
||||||
client = {
|
client = {
|
||||||
on: onStub,
|
on: onStub,
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import { transformException } from '../multer/multer.utils';
|
|||||||
type MulterInstance = any;
|
type MulterInstance = any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param localOptions
|
* @param localOptions
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export function AnyFilesInterceptor(
|
export function AnyFilesInterceptor(
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import { transformException } from '../multer/multer.utils';
|
|||||||
type MulterInstance = any;
|
type MulterInstance = any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uploadFields
|
* @param uploadFields
|
||||||
* @param localOptions
|
* @param localOptions
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export function FileFieldsInterceptor(
|
export function FileFieldsInterceptor(
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ import { transformException } from '../multer/multer.utils';
|
|||||||
type MulterInstance = any;
|
type MulterInstance = any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fieldName
|
* @param fieldName
|
||||||
* @param localOptions
|
* @param localOptions
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export function FileInterceptor(
|
export function FileInterceptor(
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import { transformException } from '../multer/multer.utils';
|
|||||||
type MulterInstance = any;
|
type MulterInstance = any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param fieldName
|
* @param fieldName
|
||||||
* @param maxCount
|
* @param maxCount
|
||||||
* @param localOptions
|
* @param localOptions
|
||||||
*
|
*
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export function FilesInterceptor(
|
export function FilesInterceptor(
|
||||||
fieldName: string,
|
fieldName: string,
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import { transformException } from '../multer/multer.utils';
|
|||||||
type MulterInstance = any;
|
type MulterInstance = any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param localOptions
|
* @param localOptions
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
export function NoFilesInterceptor(
|
export function NoFilesInterceptor(
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ export interface MulterOptionsFactory {
|
|||||||
createMulterOptions(): Promise<MulterModuleOptions> | MulterModuleOptions;
|
createMulterOptions(): Promise<MulterModuleOptions> | MulterModuleOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ type FastifyRawRequest<TServer extends RawServerBase> =
|
|||||||
export class FastifyAdapter<
|
export class FastifyAdapter<
|
||||||
TServer extends RawServerBase = RawServerDefault,
|
TServer extends RawServerBase = RawServerDefault,
|
||||||
TRawRequest extends FastifyRawRequest<TServer> = FastifyRawRequest<TServer>,
|
TRawRequest extends FastifyRawRequest<TServer> = FastifyRawRequest<TServer>,
|
||||||
TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>,
|
TRawResponse extends
|
||||||
|
RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>,
|
||||||
TRequest extends FastifyRequest<
|
TRequest extends FastifyRequest<
|
||||||
RequestGenericInterface,
|
RequestGenericInterface,
|
||||||
TServer,
|
TServer,
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { FASTIFY_ROUTE_CONFIG_METADATA } from '../constants';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @publicApi
|
* @publicApi
|
||||||
*
|
*
|
||||||
* @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#config}
|
* @param config See {@link https://fastify.dev/docs/latest/Reference/Routes/#config}
|
||||||
*/
|
*/
|
||||||
export const RouteConfig = (config: any) =>
|
export const RouteConfig = (config: any) =>
|
||||||
SetMetadata(FASTIFY_ROUTE_CONFIG_METADATA, config);
|
SetMetadata(FASTIFY_ROUTE_CONFIG_METADATA, config);
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ import { WebSocketsController } from './web-sockets-controller';
|
|||||||
|
|
||||||
export class SocketModule<
|
export class SocketModule<
|
||||||
THttpServer = any,
|
THttpServer = any,
|
||||||
TAppOptions extends NestApplicationContextOptions = NestApplicationContextOptions,
|
TAppOptions extends
|
||||||
|
NestApplicationContextOptions = NestApplicationContextOptions,
|
||||||
> {
|
> {
|
||||||
private readonly socketsContainer = new SocketsContainer();
|
private readonly socketsContainer = new SocketsContainer();
|
||||||
private applicationConfig: ApplicationConfig;
|
private applicationConfig: ApplicationConfig;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe('ExceptionFiltersContext', () => {
|
|||||||
it('should return plain ExceptionHandler object', () => {
|
it('should return plain ExceptionHandler object', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new EmptyMetadata(),
|
new EmptyMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.be.empty;
|
expect((filter as any).filters).to.be.empty;
|
||||||
@@ -41,7 +41,7 @@ describe('ExceptionFiltersContext', () => {
|
|||||||
it('should return ExceptionHandler object with exception filters', () => {
|
it('should return ExceptionHandler object with exception filters', () => {
|
||||||
const filter = exceptionFilter.create(
|
const filter = exceptionFilter.create(
|
||||||
new WithMetadata(),
|
new WithMetadata(),
|
||||||
() => ({} as any),
|
() => ({}) as any,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
expect((filter as any).filters).to.not.be.empty;
|
expect((filter as any).filters).to.not.be.empty;
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ describe('WsProxy', () => {
|
|||||||
|
|
||||||
describe('create', () => {
|
describe('create', () => {
|
||||||
it('should method return thunk', async () => {
|
it('should method return thunk', async () => {
|
||||||
const proxy = await routerProxy.create(async (client, data) => {},
|
const proxy = await routerProxy.create(
|
||||||
handler);
|
async (client, data) => {},
|
||||||
|
handler,
|
||||||
|
);
|
||||||
expect(typeof proxy === 'function').to.be.true;
|
expect(typeof proxy === 'function').to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('EventsGateway', () => {
|
|||||||
await app.listen(3000);
|
await app.listen(3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach((done) => {
|
beforeEach(done => {
|
||||||
socket = io('http://localhost:3000');
|
socket = io('http://localhost:3000');
|
||||||
socket.on('connect', () => {
|
socket.on('connect', () => {
|
||||||
done();
|
done();
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import { IS_PUBLIC_KEY } from './decorators/public.decorator';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AuthGuard implements CanActivate {
|
export class AuthGuard implements CanActivate {
|
||||||
constructor(private jwtService: JwtService, private reflector: Reflector) {}
|
constructor(
|
||||||
|
private jwtService: JwtService,
|
||||||
|
private reflector: Reflector,
|
||||||
|
) {}
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||||
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export class AppController {
|
|||||||
@Sse('sse')
|
@Sse('sse')
|
||||||
sse(): Observable<MessageEvent> {
|
sse(): Observable<MessageEvent> {
|
||||||
return interval(1000).pipe(
|
return interval(1000).pipe(
|
||||||
map((_) => ({ data: { hello: 'world' } } as MessageEvent)),
|
map((_) => ({ data: { hello: 'world' } }) as MessageEvent),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,8 @@ export default async function checkBenchmarks() {
|
|||||||
if (!codechecks.isPr()) {
|
if (!codechecks.isPr()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const baselineBenchmarks = await codechecks.getValue<Benchmarks>(
|
const baselineBenchmarks =
|
||||||
benchmarksKey,
|
await codechecks.getValue<Benchmarks>(benchmarksKey);
|
||||||
);
|
|
||||||
const report = getCodechecksReport(currentBenchmarks, baselineBenchmarks);
|
const report = getCodechecksReport(currentBenchmarks, baselineBenchmarks);
|
||||||
await codechecks.report(report);
|
await codechecks.report(report);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user