mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 15:08:37 +00:00
style: address integration tests lint errors
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
**/node_modules/**
|
||||
*.d.ts
|
||||
*.js
|
||||
47
.eslintrc.js
47
.eslintrc.js
@@ -1,47 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'prettier',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/ban-types': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.spec.ts', 'integration/**/*.ts'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.spec.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/ban-types': 'off',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
},
|
||||
}
|
||||
]
|
||||
};
|
||||
51
eslint.config.mjs
Normal file
51
eslint.config.mjs
Normal file
@@ -0,0 +1,51 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['node_modules', '**/node_modules/**', '**/*.js', '**/*.d.ts'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
ecmaVersion: 5,
|
||||
sourceType: 'module',
|
||||
parserOptions: {
|
||||
project: ['tsconfig.json', 'tsconfig.spec.json'],
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'off',
|
||||
'@typescript-eslint/no-unsafe-call': 'off',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
||||
'@typescript-eslint/no-unsafe-function-type': 'off',
|
||||
'@typescript-eslint/no-unsafe-argument': 'off',
|
||||
'@typescript-eslint/no-unsafe-return': 'off',
|
||||
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
"error",
|
||||
{
|
||||
"checksVoidReturn": false
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/require-await": "off"
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -48,6 +48,7 @@ describe('Auto-Mocking with token in factory', () => {
|
||||
expect(fooServ.foo.called);
|
||||
});
|
||||
it('cannot mock the dependencies', async () => {
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
const moduleRef = Test.createTestingModule({
|
||||
providers: [BarService],
|
||||
}).useMocker(token => {
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
"e2e/**/*",
|
||||
"test/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
||||
@@ -7,4 +7,4 @@ async function bootstrap() {
|
||||
app.useGlobalPipes(new ValidationPipe());
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -35,7 +35,7 @@ export class RecipesResolver {
|
||||
@Args('newRecipeData') newRecipeData: NewRecipeInput,
|
||||
): Promise<Recipe> {
|
||||
const recipe = await this.recipesService.create(newRecipeData);
|
||||
pubSub.publish('recipeAdded', { recipeAdded: recipe });
|
||||
void pubSub.publish('recipeAdded', { recipeAdded: recipe });
|
||||
return recipe;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('GraphQL request scoped', () => {
|
||||
],
|
||||
},
|
||||
})
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
|
||||
@@ -27,8 +27,8 @@ export class CatsResolvers {
|
||||
|
||||
@Mutation('createCat')
|
||||
async create(@Args() args: Cat): Promise<Cat> {
|
||||
const createdCat = await this.catsService.create(args);
|
||||
pubSub.publish('catCreated', { catCreated: createdCat });
|
||||
const createdCat = this.catsService.create(args);
|
||||
void pubSub.publish('catCreated', { catCreated: createdCat });
|
||||
return createdCat;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -48,7 +48,7 @@ export class HeaderInterceptor {
|
||||
const ctx = context.switchToHttp();
|
||||
const res = ctx.getResponse();
|
||||
for (const key in this.headers) {
|
||||
if (this.headers.hasOwnProperty(key)) {
|
||||
if (Object.prototype.hasOwnProperty.call(this.headers, key)) {
|
||||
res.header(key, this.headers[key]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export class HostArrayController {
|
||||
|
||||
@Get('async')
|
||||
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
|
||||
return `${await this.hostService.greeting()} tenant=${tenant}`;
|
||||
return `${this.hostService.greeting()} tenant=${tenant}`;
|
||||
}
|
||||
|
||||
@Get('stream')
|
||||
|
||||
@@ -18,7 +18,7 @@ export class HostController {
|
||||
|
||||
@Get('async')
|
||||
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
|
||||
return `${await this.hostService.greeting()} tenant=${tenant}`;
|
||||
return `${this.hostService.greeting()} tenant=${tenant}`;
|
||||
}
|
||||
|
||||
@Get('stream')
|
||||
|
||||
@@ -39,4 +39,4 @@ async function bootstrap() {
|
||||
process.kill(process.pid, SIGNAL);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -2,12 +2,11 @@ import { INestApplication } from '@nestjs/common';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import * as chai from 'chai';
|
||||
import { expect } from 'chai';
|
||||
import chaiAsPromised = require('chai-as-promised');
|
||||
import { AppModule } from '../src/app.module';
|
||||
import chaiAsPromised = require('chai-as-promised');
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
describe('Lazy imports', () => {
|
||||
let server;
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -16,7 +15,6 @@ describe('Lazy imports', () => {
|
||||
}).compile();
|
||||
|
||||
app = module.createNestApplication();
|
||||
server = app.getHttpAdapter().getInstance();
|
||||
});
|
||||
|
||||
it(`should allow imports of global modules`, async () => {
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
40
integration/lazy-modules/tsconfig.json
Normal file
40
integration/lazy-modules/tsconfig.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
"@nestjs/common/*": ["../../packages/common/*"],
|
||||
"@nestjs/core": ["../../packages/core"],
|
||||
"@nestjs/core/*": ["../../packages/core/*"],
|
||||
"@nestjs/microservices": ["../../packages/microservices"],
|
||||
"@nestjs/microservices/*": ["../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../packages/platform-socket.io"],
|
||||
"@nestjs/platform-socket.io/*": ["../../packages/platform-socket.io/*"],
|
||||
"@nestjs/platform-ws": ["../../packages/platform-ws"],
|
||||
"@nestjs/platform-ws/*": ["../../packages/platform-ws/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@@ -180,7 +180,7 @@ describe('GRPC transport', () => {
|
||||
|
||||
stream.on('error', err => {
|
||||
if (err.code !== GRPC.status.CANCELLED) {
|
||||
reject(err);
|
||||
reject(err as Error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ describe.skip('Kafka transport', function () {
|
||||
});
|
||||
|
||||
it(`/POST (async event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send()
|
||||
.end(() => {
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('MQTT transport', () => {
|
||||
}).timeout(5000);
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
@@ -87,7 +87,7 @@ describe('MQTT transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (wildcard EVENT #)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/wildcard-event')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
@@ -106,7 +106,7 @@ describe('MQTT transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (wildcard EVENT +)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/wildcard-event2')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
@@ -125,7 +125,7 @@ describe('MQTT transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (shared wildcard EVENT #)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/shared-wildcard-event')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
@@ -144,7 +144,7 @@ describe('MQTT transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (shared wildcard EVENT +)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/shared-wildcard-event2')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('NATS transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -78,7 +78,7 @@ describe('REDIS transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('RabbitMQ transport', () => {
|
||||
}).timeout(10000);
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -2,11 +2,11 @@ import { INestApplication } from '@nestjs/common';
|
||||
import { Transport } from '@nestjs/microservices';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as request from 'supertest';
|
||||
import { AppController } from '../src/tcp-tls/app.controller';
|
||||
import { ApplicationModule } from '../src/tcp-tls/app.module';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
describe('RPC TLS transport', () => {
|
||||
let server;
|
||||
@@ -109,7 +109,7 @@ describe('RPC TLS transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -94,7 +94,7 @@ describe('RPC transport', () => {
|
||||
});
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
return request(server)
|
||||
.post('/notify')
|
||||
.send([1, 2, 3, 4, 5])
|
||||
.end(() => {
|
||||
|
||||
@@ -2,15 +2,15 @@ import { Body, Controller, HttpCode, Post, Query } from '@nestjs/common';
|
||||
import {
|
||||
Client,
|
||||
ClientGrpc,
|
||||
ClientGrpcProxy,
|
||||
GrpcMethod,
|
||||
GrpcStreamCall,
|
||||
GrpcStreamMethod,
|
||||
Transport,
|
||||
ClientGrpcProxy,
|
||||
RpcException,
|
||||
Transport,
|
||||
} from '@nestjs/microservices';
|
||||
import { join } from 'path';
|
||||
import { Observable, of, catchError, from, mergeMap } from 'rxjs';
|
||||
import { catchError, from, mergeMap, Observable, of } from 'rxjs';
|
||||
|
||||
class ErrorHandlingProxy extends ClientGrpcProxy {
|
||||
serializeError(err) {
|
||||
@@ -81,7 +81,7 @@ export class GrpcController {
|
||||
});
|
||||
},
|
||||
error: err => {
|
||||
reject(err);
|
||||
reject(err as Error);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
"e2e/**/*",
|
||||
"test/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule);
|
||||
await app.listen(3001);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/websockets"],
|
||||
"@nestjs/testing/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/websockets"],
|
||||
"@nestjs/testing/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/websockets"],
|
||||
"@nestjs/testing/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { ExpressAdapter } from '@nestjs/platform-express';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import * as express from 'express';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
|
||||
describe('Listen (Express Application)', () => {
|
||||
let testModule: TestingModule;
|
||||
@@ -17,7 +17,7 @@ describe('Listen (Express Application)', () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
app.close();
|
||||
await app.close();
|
||||
});
|
||||
|
||||
it('should resolve with httpServer on success', async () => {
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('Listen (Fastify Application)', () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
app.close();
|
||||
await app.close();
|
||||
});
|
||||
|
||||
it('should resolve with httpServer on success', async () => {
|
||||
|
||||
40
integration/nest-application/listen/tsconfig.json
Normal file
40
integration/nest-application/listen/tsconfig.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../../packages/common"],
|
||||
"@nestjs/common/*": ["../../../packages/common/*"],
|
||||
"@nestjs/core": ["../../../packages/core"],
|
||||
"@nestjs/core/*": ["../../../packages/core/*"],
|
||||
"@nestjs/microservices": ["../../../packages/microservices"],
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
"@nestjs/platform-socket.io/*": ["../../../packages/platform-socket.io/*"],
|
||||
"@nestjs/platform-ws": ["../../../packages/platform-ws"],
|
||||
"@nestjs/platform-ws/*": ["../../../packages/platform-ws/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/websockets"],
|
||||
"@nestjs/testing/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
|
||||
@@ -6,7 +6,7 @@ export class AppController {
|
||||
@Sse('sse')
|
||||
sse(): Observable<MessageEvent> {
|
||||
return interval(1000).pipe(
|
||||
map(_ => ({ data: { hello: 'world' } }) as MessageEvent),
|
||||
map(() => ({ data: { hello: 'world' } }) as MessageEvent),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
"@nestjs/microservices/*": ["../../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/websockets"],
|
||||
"@nestjs/testing/*": ["../../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../../packages/platform-socket.io"],
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { clc } from '@nestjs/common/utils/cli-colors.util';
|
||||
import { repl } from '@nestjs/core';
|
||||
import { ReplContext } from '@nestjs/core/repl/repl-context';
|
||||
import {
|
||||
HelpReplFn,
|
||||
DebugReplFn,
|
||||
GetReplFn,
|
||||
HelpReplFn,
|
||||
MethodsReplFn,
|
||||
ResolveReplFn,
|
||||
SelectReplFn,
|
||||
DebugReplFn,
|
||||
MethodsReplFn,
|
||||
} from '@nestjs/core/repl/native-functions';
|
||||
import { ReplContext } from '@nestjs/core/repl/repl-context';
|
||||
import { expect } from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import { AppModule } from '../src/app.module';
|
||||
@@ -34,7 +34,7 @@ describe('REPL', () => {
|
||||
server.context;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
server.emit('line', 'get(UsersService)');
|
||||
@@ -63,7 +63,7 @@ ${PROMPT}`);
|
||||
server.context;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
server.emit('line', '$(UsersService)');
|
||||
@@ -92,7 +92,7 @@ ${PROMPT}`);
|
||||
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
server.emit('line', 'debug(UsersModule)');
|
||||
@@ -115,7 +115,7 @@ ${PROMPT}`,
|
||||
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
server.emit('line', 'methods("UsersRepository")');
|
||||
@@ -153,7 +153,7 @@ ${PROMPT}`,
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -172,7 +172,7 @@ ${PROMPT}`);
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ ${PROMPT}`);
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -210,7 +210,7 @@ ${PROMPT}`);
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -229,7 +229,7 @@ ${PROMPT}`);
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ ${PROMPT}`);
|
||||
).fnDefinition;
|
||||
let outputText = '';
|
||||
sinon.stub(process.stdout, 'write').callsFake(text => {
|
||||
outputText += text;
|
||||
outputText += text as string;
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@@ -48,19 +48,19 @@ describe('Circular request scope', () => {
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should create controller for each request`, async () => {
|
||||
it(`should create controller for each request`, () => {
|
||||
expect(HelloController.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
it(`should create service for each request`, () => {
|
||||
expect(UsersService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
it(`should create service for each request`, () => {
|
||||
expect(HelloService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create provider for each inquirer`, async () => {
|
||||
it(`should create provider for each inquirer`, () => {
|
||||
expect(Meta.COUNTER).to.be.eql(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('Circular transient scope', () => {
|
||||
const performHttpCall = end =>
|
||||
request(server)
|
||||
.get('/hello')
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
|
||||
@@ -47,29 +47,29 @@ describe('Request scope (microservices)', () => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should create controller for each request`, async () => {
|
||||
it(`should create controller for each request`, () => {
|
||||
expect(HelloController.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
it(`should create service for each request`, () => {
|
||||
expect(UsersService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should share static provider across requests`, async () => {
|
||||
it(`should share static provider across requests`, () => {
|
||||
expect(Meta.COUNTER).to.be.eql(1);
|
||||
});
|
||||
|
||||
it(`should create request scoped interceptor for each request`, async () => {
|
||||
it(`should create request scoped interceptor for each request`, () => {
|
||||
expect(Interceptor.COUNTER).to.be.eql(3);
|
||||
expect(Interceptor.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
|
||||
it(`should create request scoped guard for each request`, async () => {
|
||||
it(`should create request scoped guard for each request`, () => {
|
||||
expect(Guard.COUNTER).to.be.eql(3);
|
||||
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
|
||||
@@ -24,16 +24,16 @@ describe('Request scope (modules propagation)', () => {
|
||||
const performHttpCall = end =>
|
||||
request(server)
|
||||
.get('/hello')
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should not fail`, async () => {
|
||||
it(`should not fail`, () => {
|
||||
expect(RequestChainService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,38 +40,38 @@ describe('Request scope', () => {
|
||||
const performHttpCall = end =>
|
||||
request(server)
|
||||
.get('/hello')
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should create controller for each request`, async () => {
|
||||
it(`should create controller for each request`, () => {
|
||||
expect(HelloController.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
it(`should create service for each request`, () => {
|
||||
expect(UsersService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should share static provider across requests`, async () => {
|
||||
it(`should share static provider across requests`, () => {
|
||||
expect(Meta.COUNTER).to.be.eql(1);
|
||||
});
|
||||
|
||||
it(`should create request scoped pipe for each request`, async () => {
|
||||
it(`should create request scoped pipe for each request`, () => {
|
||||
expect(UserByIdPipe.COUNTER).to.be.eql(3);
|
||||
expect(UserByIdPipe.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
|
||||
it(`should create request scoped interceptor for each request`, async () => {
|
||||
it(`should create request scoped interceptor for each request`, () => {
|
||||
expect(Interceptor.COUNTER).to.be.eql(3);
|
||||
expect(Interceptor.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
|
||||
it(`should create request scoped guard for each request`, async () => {
|
||||
it(`should create request scoped guard for each request`, () => {
|
||||
expect(Guard.COUNTER).to.be.eql(3);
|
||||
expect(Guard.REQUEST_SCOPED_DATA).to.deep.equal([1, 1, 1]);
|
||||
});
|
||||
|
||||
@@ -41,36 +41,36 @@ describe('Transient scope', () => {
|
||||
const performHttpCall = end =>
|
||||
request(server)
|
||||
.get('/hello')
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
await new Promise<any>(resolve => performHttpCall(resolve));
|
||||
});
|
||||
|
||||
it(`should create controller for each request`, async () => {
|
||||
it(`should create controller for each request`, () => {
|
||||
expect(HelloController.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create service for each request`, async () => {
|
||||
it(`should create service for each request`, () => {
|
||||
expect(UsersService.COUNTER).to.be.eql(3);
|
||||
});
|
||||
|
||||
it(`should create provider for each inquirer`, async () => {
|
||||
it(`should create provider for each inquirer`, () => {
|
||||
expect(Meta.COUNTER).to.be.eql(7);
|
||||
});
|
||||
|
||||
it(`should create transient pipe for each controller (3 requests, 1 static)`, async () => {
|
||||
it(`should create transient pipe for each controller (3 requests, 1 static)`, () => {
|
||||
expect(UserByIdPipe.COUNTER).to.be.eql(4);
|
||||
});
|
||||
|
||||
it(`should create transient interceptor for each controller (3 requests, 1 static)`, async () => {
|
||||
it(`should create transient interceptor for each controller (3 requests, 1 static)`, () => {
|
||||
expect(Interceptor.COUNTER).to.be.eql(4);
|
||||
});
|
||||
|
||||
it(`should create transient guard for each controller (3 requests, 1 static)`, async () => {
|
||||
it(`should create transient guard for each controller (3 requests, 1 static)`, () => {
|
||||
expect(Guard.COUNTER).to.be.eql(4);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
Injectable,
|
||||
PipeTransform,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { Injectable, PipeTransform, Scope } from '@nestjs/common';
|
||||
|
||||
@Injectable({ scope: Scope.TRANSIENT })
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
@@ -12,7 +7,7 @@ export class UserByIdPipe implements PipeTransform<string> {
|
||||
UserByIdPipe.COUNTER++;
|
||||
}
|
||||
|
||||
transform(value: string, metadata: ArgumentMetadata) {
|
||||
transform(value: string) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { IncomingMessage, request, RequestOptions } from 'http';
|
||||
import { IncomingMessage, request } from 'http';
|
||||
import { URL } from 'url';
|
||||
|
||||
export const getHttpBaseOptions = async (
|
||||
@@ -10,7 +10,7 @@ export const getHttpBaseOptions = async (
|
||||
};
|
||||
|
||||
export const sendCanceledHttpRequest = async (url: URL) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(resolve => {
|
||||
const req = request(url, res => {
|
||||
// close the request once we get the first response of data
|
||||
res.on('data', () => {
|
||||
@@ -29,7 +29,7 @@ export const sendHttpRequest = async (url: URL) => {
|
||||
const req = request(url, res => {
|
||||
// this makes sure that the response actually starts and is read. We could verify this value against the same
|
||||
// that is in an earlier test, but all we care about in _this_ test is that the status code is 200
|
||||
res.on('data', chunk => {
|
||||
res.on('data', () => {
|
||||
// no op
|
||||
});
|
||||
// fail the test if something goes wrong
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, Module, forwardRef } from '@nestjs/common';
|
||||
import { BModule, BProvider } from './b.module';
|
||||
import { BModule } from './b.module';
|
||||
|
||||
@Injectable()
|
||||
export class AProvider {}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, Module, forwardRef } from '@nestjs/common';
|
||||
import { AModule, AProvider } from './a.module';
|
||||
import { AModule } from './a.module';
|
||||
|
||||
@Injectable()
|
||||
export class BProvider {}
|
||||
@@ -9,9 +9,8 @@ import {
|
||||
import { LazyModuleLoader } from '@nestjs/core';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import { AModule, AProvider } from './circular-dependency/a.module';
|
||||
import { BModule, BProvider } from './circular-dependency/b.module';
|
||||
import { AModule, AProvider } from '../circular-dependency/a.module';
|
||||
import { BModule, BProvider } from '../circular-dependency/b.module';
|
||||
|
||||
describe('Modules overriding', () => {
|
||||
describe('Top-level module', () => {
|
||||
|
||||
@@ -11,7 +11,25 @@
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
"@nestjs/common/*": ["../../packages/common/*"],
|
||||
"@nestjs/core": ["../../packages/core"],
|
||||
"@nestjs/core/*": ["../../packages/core/*"],
|
||||
"@nestjs/microservices": ["../../packages/microservices"],
|
||||
"@nestjs/microservices/*": ["../../packages/microservices/*"],
|
||||
"@nestjs/websockets": ["../../packages/websockets"],
|
||||
"@nestjs/websockets/*": ["../../packages/websockets/*"],
|
||||
"@nestjs/testing": ["../../packages/testing"],
|
||||
"@nestjs/testing/*": ["../../packages/testing/*"],
|
||||
"@nestjs/platform-express": ["../../packages/platform-express"],
|
||||
"@nestjs/platform-express/*": ["../../packages/platform-express/*"],
|
||||
"@nestjs/platform-socket.io": ["../../packages/platform-socket.io"],
|
||||
"@nestjs/platform-socket.io/*": ["../../packages/platform-socket.io/*"],
|
||||
"@nestjs/platform-ws": ["../../packages/platform-ws"],
|
||||
"@nestjs/platform-ws/*": ["../../packages/platform-ws/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
"include": ["src/**/*", "e2e/**/*"],
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3001);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { INestApplication, VersioningType } from '@nestjs/common';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication,
|
||||
|
||||
@@ -12,4 +12,4 @@ async function bootstrap() {
|
||||
await app.listen(3000);
|
||||
console.log(`Application is running on: ${await app.getUrl()}`);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('ErrorGateway', () => {
|
||||
const testingModule = await Test.createTestingModule({
|
||||
providers: [ErrorGateway],
|
||||
}).compile();
|
||||
app = await testingModule.createNestApplication();
|
||||
app = testingModule.createNestApplication();
|
||||
await app.listen(3000);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-base-to-string */
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { WsAdapter } from '@nestjs/platform-ws';
|
||||
import { Test } from '@nestjs/testing';
|
||||
@@ -10,7 +11,7 @@ import { ServerGateway } from '../src/server.gateway';
|
||||
import { WsPathGateway } from '../src/ws-path.gateway';
|
||||
import { WsPathGateway2 } from '../src/ws-path2.gateway';
|
||||
|
||||
async function createNestApp(...gateways): Promise<INestApplication> {
|
||||
async function createNestApp(...gateways: any[]): Promise<INestApplication> {
|
||||
const testingModule = await Test.createTestingModule({
|
||||
providers: gateways,
|
||||
}).compile();
|
||||
@@ -20,7 +21,7 @@ async function createNestApp(...gateways): Promise<INestApplication> {
|
||||
}
|
||||
|
||||
describe('WebSocketGateway (WsAdapter)', () => {
|
||||
let ws, ws2, app;
|
||||
let ws: WebSocket, ws2: WebSocket, app: INestApplication;
|
||||
|
||||
it(`should handle message (2nd port)`, async () => {
|
||||
app = await createNestApp(ApplicationGateway);
|
||||
@@ -39,7 +40,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
@@ -63,7 +64,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
@@ -90,7 +91,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
@@ -115,7 +116,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('open', () => {
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
});
|
||||
@@ -132,7 +133,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
|
||||
await new Promise<void>(resolve => {
|
||||
ws2.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws2.close();
|
||||
resolve();
|
||||
});
|
||||
@@ -162,7 +163,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('open', () => {
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
});
|
||||
@@ -179,7 +180,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
|
||||
await new Promise<void>(resolve => {
|
||||
ws2.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws2.close();
|
||||
resolve();
|
||||
});
|
||||
@@ -211,7 +212,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
);
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.path).to.be.eql('getClient');
|
||||
expect(JSON.parse(data.toString()).data.path).to.be.eql('getClient');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
@@ -238,7 +239,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
ws.send(JSON.stringify(['push', { test: 'test' }]));
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
@@ -266,7 +267,7 @@ describe('WebSocketGateway (WsAdapter)', () => {
|
||||
ws.send(JSON.stringify(['push', { test: 'test' }]));
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('message', data => {
|
||||
expect(JSON.parse(data).data.test).to.be.eql('test');
|
||||
expect(JSON.parse(data.toString()).data.test).to.be.eql('test');
|
||||
ws.close();
|
||||
resolve();
|
||||
}),
|
||||
|
||||
@@ -8,7 +8,7 @@ import { throwError } from 'rxjs';
|
||||
@WebSocketGateway(8080)
|
||||
export class ErrorGateway {
|
||||
@SubscribeMessage('push')
|
||||
onPush(client, data) {
|
||||
onPush() {
|
||||
return throwError(() => new WsException('test'));
|
||||
}
|
||||
}
|
||||
|
||||
1237
package-lock.json
generated
1237
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -82,6 +82,8 @@
|
||||
"@codechecks/client": "0.1.12",
|
||||
"@commitlint/cli": "19.5.0",
|
||||
"@commitlint/config-angular": "19.5.0",
|
||||
"@eslint/eslintrc": "3.2.0",
|
||||
"@eslint/js": "9.15.0",
|
||||
"@fastify/cors": "9.0.1",
|
||||
"@fastify/formbody": "7.4.0",
|
||||
"@fastify/middie": "8.3.1",
|
||||
@@ -99,6 +101,7 @@
|
||||
"@types/chai": "4.3.16",
|
||||
"@types/chai-as-promised": "7.1.8",
|
||||
"@types/cors": "2.8.17",
|
||||
"@types/eslint__js": "8.42.3",
|
||||
"@types/express": "4.17.21",
|
||||
"@types/gulp": "4.0.17",
|
||||
"@types/http-errors": "2.0.4",
|
||||
@@ -107,8 +110,6 @@
|
||||
"@types/sinon": "17.0.3",
|
||||
"@types/supertest": "2.0.16",
|
||||
"@types/ws": "8.5.12",
|
||||
"@typescript-eslint/eslint-plugin": "7.18.0",
|
||||
"@typescript-eslint/parser": "7.18.0",
|
||||
"amqp-connection-manager": "4.1.14",
|
||||
"amqplib": "0.10.4",
|
||||
"artillery": "2.0.20",
|
||||
@@ -125,12 +126,14 @@
|
||||
"coveralls": "3.1.1",
|
||||
"delete-empty": "3.0.0",
|
||||
"engine.io-client": "6.6.1",
|
||||
"eslint": "8.57.1",
|
||||
"eslint": "9.15.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-prettier": "5.2.1",
|
||||
"eventsource": "2.0.2",
|
||||
"fancy-log": "2.0.0",
|
||||
"fastify": "4.28.1",
|
||||
"globals": "15.12.0",
|
||||
"graphql": "16.9.0",
|
||||
"graphql-tools": "9.0.1",
|
||||
"gulp": "4.0.2",
|
||||
@@ -170,6 +173,7 @@
|
||||
"ts-node": "10.9.2",
|
||||
"typeorm": "0.3.20",
|
||||
"typescript": "5.6.2",
|
||||
"typescript-eslint": "8.15.0",
|
||||
"wrk": "1.2.1",
|
||||
"ws": "8.18.0"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
import { EXCEPTION_FILTERS_METADATA } from '../../constants';
|
||||
import { ExceptionFilter } from '../../index';
|
||||
import { extendArrayMetadata } from '../../utils/extend-metadata.util';
|
||||
@@ -40,9 +39,7 @@ function addExceptionFiltersMetadata(
|
||||
) => {
|
||||
const isFilterValid = <T extends Function | Record<string, any>>(
|
||||
filter: T,
|
||||
) =>
|
||||
filter &&
|
||||
(isFunction(filter) || isFunction((filter as Record<string, any>).catch));
|
||||
) => filter && (isFunction(filter) || isFunction(filter.catch));
|
||||
|
||||
if (descriptor) {
|
||||
validateEach(
|
||||
|
||||
@@ -34,9 +34,7 @@ export function UseGuards(
|
||||
descriptor?: TypedPropertyDescriptor<any>,
|
||||
) => {
|
||||
const isGuardValid = <T extends Function | Record<string, any>>(guard: T) =>
|
||||
guard &&
|
||||
(isFunction(guard) ||
|
||||
isFunction((guard as Record<string, any>).canActivate));
|
||||
guard && (isFunction(guard) || isFunction(guard.canActivate));
|
||||
|
||||
if (descriptor) {
|
||||
validateEach(
|
||||
|
||||
@@ -37,8 +37,7 @@ export function UseInterceptors(
|
||||
interceptor: T,
|
||||
) =>
|
||||
interceptor &&
|
||||
(isFunction(interceptor) ||
|
||||
isFunction((interceptor as Record<string, any>).intercept));
|
||||
(isFunction(interceptor) || isFunction(interceptor.intercept));
|
||||
|
||||
if (descriptor) {
|
||||
validateEach(
|
||||
|
||||
@@ -35,8 +35,7 @@ export function UsePipes(
|
||||
descriptor?: TypedPropertyDescriptor<any>,
|
||||
) => {
|
||||
const isPipeValid = <T extends Function | Record<string, any>>(pipe: T) =>
|
||||
pipe &&
|
||||
(isFunction(pipe) || isFunction((pipe as Record<string, any>).transform));
|
||||
pipe && (isFunction(pipe) || isFunction(pipe.transform));
|
||||
|
||||
if (descriptor) {
|
||||
extendArrayMetadata(PIPES_METADATA, pipes, descriptor.value);
|
||||
|
||||
@@ -86,11 +86,8 @@ export class HttpException extends Error {
|
||||
public initMessage() {
|
||||
if (isString(this.response)) {
|
||||
this.message = this.response;
|
||||
} else if (
|
||||
isObject(this.response) &&
|
||||
isString((this.response as Record<string, any>).message)
|
||||
) {
|
||||
this.message = (this.response as Record<string, any>).message;
|
||||
} else if (isObject(this.response) && isString(this.response.message)) {
|
||||
this.message = this.response.message;
|
||||
} else if (this.constructor) {
|
||||
this.message =
|
||||
this.constructor.name.match(/[A-Z][a-z]+|[0-9]+/g)?.join(' ') ??
|
||||
|
||||
@@ -126,8 +126,8 @@ export class ParseArrayPipe implements PipeTransform {
|
||||
targetArray[i] = await toClassInstance(targetArray[i]);
|
||||
} catch (err) {
|
||||
let message: string[] | unknown;
|
||||
if ((err as any).getResponse) {
|
||||
const response = (err as any).getResponse();
|
||||
if (err.getResponse) {
|
||||
const response = err.getResponse();
|
||||
if (Array.isArray(response.message)) {
|
||||
message = response.message.map(
|
||||
(item: string) => `[${i}] ${item}`,
|
||||
|
||||
@@ -54,9 +54,7 @@ export class ParseDatePipe
|
||||
*/
|
||||
transform(value: string | number | undefined | null): Date {
|
||||
if (this.options.optional && isNil(value)) {
|
||||
return this.options.default
|
||||
? this.options.default()
|
||||
: (value as undefined | null);
|
||||
return this.options.default ? this.options.default() : value;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
|
||||
@@ -142,7 +142,7 @@ export class ConsoleLogger implements LoggerService {
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [context, opts] = isString(contextOrOptions)
|
||||
? [contextOrOptions, options]
|
||||
: !!options
|
||||
: options
|
||||
? [undefined, options]
|
||||
: [contextOrOptions?.context, contextOrOptions];
|
||||
|
||||
@@ -515,7 +515,7 @@ export class ConsoleLogger implements LoggerService {
|
||||
return { messages: args, context: this.context };
|
||||
}
|
||||
return {
|
||||
context: lastElement as string,
|
||||
context: lastElement,
|
||||
messages: args.slice(0, args.length - 1),
|
||||
};
|
||||
}
|
||||
@@ -545,7 +545,7 @@ export class ConsoleLogger implements LoggerService {
|
||||
return { messages, context };
|
||||
}
|
||||
return {
|
||||
stack: lastElement as string,
|
||||
stack: lastElement,
|
||||
messages: messages.slice(0, messages.length - 1),
|
||||
context,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@ describe('loadPackage', () => {
|
||||
describe('when package is available', () => {
|
||||
it('should return package', () => {
|
||||
expect(loadPackage('reflect-metadata', 'ctx')).to.be.eql(
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
require('reflect-metadata'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
export const isUndefined = (obj: any): obj is undefined =>
|
||||
typeof obj === 'undefined';
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ export abstract class AbstractHttpAdapter<
|
||||
|
||||
constructor(protected instance?: any) {}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
public async init() {}
|
||||
|
||||
public use(...args: any[]) {
|
||||
@@ -129,7 +128,7 @@ export abstract class AbstractHttpAdapter<
|
||||
}
|
||||
|
||||
public getHttpServer(): TServer {
|
||||
return this.httpServer as TServer;
|
||||
return this.httpServer;
|
||||
}
|
||||
|
||||
public setHttpServer(httpServer: TServer) {
|
||||
|
||||
@@ -70,8 +70,6 @@ export async function callBeforeAppShutdownHook(
|
||||
hasBeforeApplicationShutdownHook(moduleClassInstance) &&
|
||||
moduleClassHost.isDependencyTreeStatic()
|
||||
) {
|
||||
await (
|
||||
moduleClassInstance as BeforeApplicationShutdown
|
||||
).beforeApplicationShutdown(signal);
|
||||
await moduleClassInstance.beforeApplicationShutdown(signal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,6 @@ export async function callModuleBootstrapHook(module: Module): Promise<any> {
|
||||
hasOnAppBootstrapHook(moduleClassInstance) &&
|
||||
moduleClassHost.isDependencyTreeStatic()
|
||||
) {
|
||||
await (
|
||||
moduleClassInstance as OnApplicationBootstrap
|
||||
).onApplicationBootstrap();
|
||||
await moduleClassInstance.onApplicationBootstrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,6 @@ export async function callAppShutdownHook(
|
||||
hasOnAppShutdownHook(moduleClassInstance) &&
|
||||
moduleClassHost.isDependencyTreeStatic()
|
||||
) {
|
||||
await (moduleClassInstance as OnApplicationShutdown).onApplicationShutdown(
|
||||
signal,
|
||||
);
|
||||
await moduleClassInstance.onApplicationShutdown(signal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,6 @@ export async function callModuleDestroyHook(module: Module): Promise<any> {
|
||||
hasOnModuleDestroyHook(moduleClassInstance) &&
|
||||
moduleClassHost.isDependencyTreeStatic()
|
||||
) {
|
||||
await (moduleClassInstance as OnModuleDestroy).onModuleDestroy();
|
||||
await moduleClassInstance.onModuleDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,6 @@ export async function callModuleInitHook(module: Module): Promise<void> {
|
||||
hasOnModuleInitHook(moduleClassInstance) &&
|
||||
moduleClassHost.isDependencyTreeStatic()
|
||||
) {
|
||||
await (moduleClassInstance as OnModuleInit).onModuleInit();
|
||||
await moduleClassInstance.onModuleInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => {};
|
||||
export class SilentLogger extends Logger {
|
||||
log = noop;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Provider, Scope } from '@nestjs/common';
|
||||
import { INQUIRER } from './inquirer-constants';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => {};
|
||||
export const inquirerProvider: Provider = {
|
||||
provide: INQUIRER,
|
||||
|
||||
@@ -338,7 +338,7 @@ export class InstanceWrapper<T = any> {
|
||||
|
||||
public isInRequestScope(
|
||||
contextId: ContextId,
|
||||
inquirer?: InstanceWrapper | undefined,
|
||||
inquirer?: InstanceWrapper,
|
||||
): boolean {
|
||||
const isDependencyTreeStatic = this.isDependencyTreeStatic();
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { GraphInspector } from './graph-inspector';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => {};
|
||||
export const NoopGraphInspector: GraphInspector = new Proxy(
|
||||
GraphInspector.prototype,
|
||||
|
||||
@@ -52,7 +52,7 @@ export const mapToClass = <T extends Function | Type<any>>(
|
||||
if (excludedRoutes.length <= 0) {
|
||||
return middleware;
|
||||
}
|
||||
const MiddlewareHost = class extends (middleware as Type<any>) {
|
||||
const MiddlewareHost = class extends middleware {
|
||||
use(...params: unknown[]) {
|
||||
const [req, _, next] = params as [Record<string, any>, any, Function];
|
||||
const isExcluded = isMiddlewareRouteExcluded(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Provider, Scope } from '@nestjs/common';
|
||||
import { REQUEST } from './request-constants';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => {};
|
||||
export const requestProvider: Provider = {
|
||||
provide: REQUEST,
|
||||
|
||||
@@ -225,9 +225,8 @@ export class RouterExplorer {
|
||||
requestMethod: RequestMethod[
|
||||
requestMethod
|
||||
] as keyof typeof RequestMethod,
|
||||
methodVersion: routePathMetadata.methodVersion as VersionValue,
|
||||
controllerVersion:
|
||||
routePathMetadata.controllerVersion as VersionValue,
|
||||
methodVersion: routePathMetadata.methodVersion,
|
||||
controllerVersion: routePathMetadata.controllerVersion,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ export class DependenciesScanner {
|
||||
});
|
||||
};
|
||||
|
||||
const rootModule = modulesGenerator.next().value as Module;
|
||||
const rootModule = modulesGenerator.next().value;
|
||||
calculateDistance(rootModule);
|
||||
}
|
||||
|
||||
@@ -438,17 +438,11 @@ export class DependenciesScanner {
|
||||
public insertProvider(provider: Provider, token: string) {
|
||||
const isCustomProvider = this.isCustomProvider(provider);
|
||||
if (!isCustomProvider) {
|
||||
return this.container.addProvider(provider as Type<any>, token);
|
||||
return this.container.addProvider(provider, token);
|
||||
}
|
||||
const applyProvidersMap = this.getApplyProvidersMap();
|
||||
const providersKeys = Object.keys(applyProvidersMap);
|
||||
const type = (
|
||||
provider as
|
||||
| ClassProvider
|
||||
| ValueProvider
|
||||
| FactoryProvider
|
||||
| ExistingProvider
|
||||
).provide;
|
||||
const type = provider.provide;
|
||||
|
||||
if (!providersKeys.includes(type as string)) {
|
||||
return this.container.addProvider(provider as any, token);
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('ExternalContextCreator', () => {
|
||||
contextCreator,
|
||||
'getContextModuleKey',
|
||||
);
|
||||
contextCreator.create({ foo: 'bar' }, callback as any, '', '', null);
|
||||
contextCreator.create({ foo: 'bar' }, callback, '', '', null);
|
||||
expect(getContextModuleKeySpy.called).to.be.true;
|
||||
done();
|
||||
});
|
||||
@@ -65,13 +65,7 @@ describe('ExternalContextCreator', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
instance = { foo: 'bar' };
|
||||
proxyContext = contextCreator.create(
|
||||
instance,
|
||||
callback as any,
|
||||
'',
|
||||
'',
|
||||
null,
|
||||
);
|
||||
proxyContext = contextCreator.create(instance, callback, '', '', null);
|
||||
});
|
||||
it('should be a function', () => {
|
||||
expect(proxyContext).to.be.a('function');
|
||||
|
||||
@@ -126,7 +126,7 @@ describe('provider classifier', () => {
|
||||
useFactory: undefined,
|
||||
};
|
||||
|
||||
expect(isFactoryProvider(factoryProvider as FactoryProvider)).to.be.false;
|
||||
expect(isFactoryProvider(factoryProvider)).to.be.false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useValue: 'test' };
|
||||
|
||||
moduleRef.addProvider(provider as any);
|
||||
expect((addCustomProvider as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomProvider.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should call "addCustomClass" when "useClass" property exists', () => {
|
||||
@@ -126,7 +126,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useClass: () => null };
|
||||
|
||||
moduleRef.addCustomProvider(provider as any, new Map());
|
||||
expect((addCustomClass as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomClass.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should call "addCustomValue" when "useValue" property exists', () => {
|
||||
@@ -136,7 +136,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useValue: () => null };
|
||||
|
||||
moduleRef.addCustomProvider(provider as any, new Map());
|
||||
expect((addCustomValue as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomValue.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should call "addCustomValue" when "useValue" property exists but its value is `undefined`', () => {
|
||||
@@ -146,7 +146,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useValue: undefined };
|
||||
|
||||
moduleRef.addCustomProvider(provider as any, new Map());
|
||||
expect((addCustomValue as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomValue.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should call "addCustomFactory" when "useFactory" property exists', () => {
|
||||
@@ -156,7 +156,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useFactory: () => null };
|
||||
|
||||
moduleRef.addCustomProvider(provider as any, new Map());
|
||||
expect((addCustomFactory as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomFactory.called).to.be.true;
|
||||
});
|
||||
|
||||
it('should call "addCustomUseExisting" when "useExisting" property exists', () => {
|
||||
@@ -166,7 +166,7 @@ describe('Module', () => {
|
||||
const provider = { provide: 'test', useExisting: () => null };
|
||||
|
||||
moduleRef.addCustomUseExisting(provider as any, new Map());
|
||||
expect((addCustomUseExisting as sinon.SinonSpy).called).to.be.true;
|
||||
expect(addCustomUseExisting.called).to.be.true;
|
||||
});
|
||||
|
||||
describe('addCustomClass', () => {
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('InterceptorsContextCreator', () => {
|
||||
};
|
||||
applicationConfig = new ApplicationConfig();
|
||||
interceptorsContextCreator = new InterceptorsContextCreator(
|
||||
container as any,
|
||||
container,
|
||||
applicationConfig,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -75,12 +75,12 @@ describe('middleware utils', () => {
|
||||
expect(metatype).to.not.eql(fnMiddleware);
|
||||
});
|
||||
it('should define a `use` method', () => {
|
||||
const metatype = mapToClass(fnMiddleware, [], noopAdapter) as Type<any>;
|
||||
const metatype = mapToClass(fnMiddleware, [], noopAdapter);
|
||||
expect(new metatype().use).to.exist;
|
||||
});
|
||||
it('should encapsulate a function', () => {
|
||||
const spy = sinon.spy();
|
||||
const metatype = mapToClass(spy, [], noopAdapter) as Type<any>;
|
||||
const metatype = mapToClass(spy, [], noopAdapter);
|
||||
new metatype().use();
|
||||
expect(spy.called).to.be.true;
|
||||
});
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('RouterExecutionContext', () => {
|
||||
it('should call "exchangeKeysForValues" with expected arguments', done => {
|
||||
const keys = Object.keys(metadata);
|
||||
|
||||
contextCreator.create({ foo: 'bar' }, callback as any, '', '', 0);
|
||||
contextCreator.create({ foo: 'bar' }, callback, '', '', 0);
|
||||
expect(exchangeKeysForValuesSpy.called).to.be.true;
|
||||
expect(exchangeKeysForValuesSpy.calledWith(keys, metadata)).to.be.true;
|
||||
done();
|
||||
@@ -105,13 +105,7 @@ describe('RouterExecutionContext', () => {
|
||||
tryActivateStub = sinon
|
||||
.stub(guardsConsumer, 'tryActivate')
|
||||
.callsFake(async () => true);
|
||||
proxyContext = contextCreator.create(
|
||||
instance,
|
||||
callback as any,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
);
|
||||
proxyContext = contextCreator.create(instance, callback, '', '', 0);
|
||||
});
|
||||
it('should be a function', () => {
|
||||
expect(proxyContext).to.be.a('function');
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
isNil,
|
||||
isSymbol,
|
||||
} from '@nestjs/common/utils/shared.utils';
|
||||
/* eslint-disable @typescript-eslint/no-use-before-define */
|
||||
|
||||
import {
|
||||
PATTERN_HANDLER_METADATA,
|
||||
PATTERN_METADATA,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable prefer-spread */
|
||||
import { ArgumentsHost, Logger, RpcExceptionFilter } from '@nestjs/common';
|
||||
import { isObject } from '@nestjs/common/utils/shared.utils';
|
||||
import { MESSAGES } from '@nestjs/core/constants';
|
||||
|
||||
@@ -20,19 +20,19 @@ export class ServerFactory {
|
||||
>;
|
||||
switch (transport) {
|
||||
case Transport.REDIS:
|
||||
return new ServerRedis(options as ServerRedis['options']);
|
||||
return new ServerRedis(options);
|
||||
case Transport.NATS:
|
||||
return new ServerNats(options as ServerNats['options']);
|
||||
return new ServerNats(options);
|
||||
case Transport.MQTT:
|
||||
return new ServerMqtt(options as MqttOptions['options']);
|
||||
return new ServerMqtt(options);
|
||||
case Transport.GRPC:
|
||||
return new ServerGrpc(options as ServerGrpc['options']);
|
||||
return new ServerGrpc(options);
|
||||
case Transport.KAFKA:
|
||||
return new ServerKafka(options as ServerKafka['options']);
|
||||
return new ServerKafka(options);
|
||||
case Transport.RMQ:
|
||||
return new ServerRMQ(options as ServerRMQ['options']);
|
||||
return new ServerRMQ(options);
|
||||
default:
|
||||
return new ServerTCP(options as ServerTCP['options']);
|
||||
return new ServerTCP(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ export class ServerGrpc extends Server<never, never> {
|
||||
const drain = () => {
|
||||
writing = true;
|
||||
while (valuesWaitingToBeDrained.length > 0) {
|
||||
const value = valuesWaitingToBeDrained.shift()!;
|
||||
const value = valuesWaitingToBeDrained.shift();
|
||||
if (writing) {
|
||||
// The first time `call.write` returns false, we need to stop.
|
||||
// It wrote the value, but it won't write anything else.
|
||||
|
||||
@@ -179,7 +179,7 @@ export class ServerNats<
|
||||
|
||||
// In case the "reply" topic is not provided, there's no need for a reply.
|
||||
// Method returns a noop function instead
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
|
||||
return () => {};
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ describe('ClientMqtt', () => {
|
||||
on: (ev, callback) => callback(error),
|
||||
off: () => ({}),
|
||||
};
|
||||
client.mergeCloseEvent(instance as any, EMPTY).subscribe({
|
||||
client.mergeCloseEvent(instance, EMPTY).subscribe({
|
||||
error: (err: any) => expect(err).to.be.eql(error),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -174,7 +174,7 @@ describe('ClientRMQ', function () {
|
||||
off: () => ({}),
|
||||
};
|
||||
client
|
||||
.mergeDisconnectEvent(instance as any, EMPTY)
|
||||
.mergeDisconnectEvent(instance, EMPTY)
|
||||
.subscribe({ error: (err: any) => expect(err).to.be.eql(error) });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('kafka reply partition assigner', () => {
|
||||
getPreviousAssignment = sinon.spy(assigner, 'getPreviousAssignment');
|
||||
|
||||
// reset previous assignments
|
||||
(client as any).consumerAssignments = {};
|
||||
client.consumerAssignments = {};
|
||||
});
|
||||
|
||||
describe('assign', () => {
|
||||
@@ -259,7 +259,7 @@ describe('kafka reply partition assigner', () => {
|
||||
describe('protocol', () => {
|
||||
it('returns the assigner name and metadata', () => {
|
||||
// set previous assignments
|
||||
(client as any).consumerAssignments = {
|
||||
client.consumerAssignments = {
|
||||
'topic-A': 0,
|
||||
'topic-B': 1,
|
||||
};
|
||||
@@ -276,7 +276,7 @@ describe('kafka reply partition assigner', () => {
|
||||
topics,
|
||||
userData: Buffer.from(
|
||||
JSON.stringify({
|
||||
previousAssignment: (client as any).consumerAssignments,
|
||||
previousAssignment: client.consumerAssignments,
|
||||
}),
|
||||
),
|
||||
}),
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('ListenersController', () => {
|
||||
server: any,
|
||||
serverTCP: any,
|
||||
serverCustom: any,
|
||||
customTransport: Symbol,
|
||||
customTransport: symbol,
|
||||
addSpy: sinon.SinonSpy,
|
||||
addSpyTCP: sinon.SinonSpy,
|
||||
addSpyCustom: sinon.SinonSpy,
|
||||
|
||||
@@ -98,9 +98,7 @@ describe('ClientsModule', () => {
|
||||
createClientOptions: sinon.spy(),
|
||||
};
|
||||
try {
|
||||
await ((dynamicModule.providers[0] as any).useFactory as any)(
|
||||
optionsFactory,
|
||||
);
|
||||
await (dynamicModule.providers[0] as any).useFactory(optionsFactory);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user