mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
chore: resolve conflicts
This commit is contained in:
@@ -6,16 +6,16 @@ parameters:
|
||||
default: false
|
||||
legacy-node-version:
|
||||
type: string
|
||||
default: '14.21.3'
|
||||
default: '18.20'
|
||||
maintenance-node-version:
|
||||
type: string
|
||||
default: '16.20'
|
||||
default: '20.5'
|
||||
active-node-version:
|
||||
type: string
|
||||
default: '18.17'
|
||||
default: '22.11'
|
||||
current-node-version:
|
||||
type: string
|
||||
default: '20.5'
|
||||
default: '23.3'
|
||||
|
||||
aliases:
|
||||
- &restore-cache
|
||||
@@ -121,14 +121,14 @@ jobs:
|
||||
lint:
|
||||
working_directory: ~/nest
|
||||
docker:
|
||||
- image: cimg/node:<< pipeline.parameters.current-node-version >>
|
||||
- image: cimg/node:<< pipeline.parameters.active-node-version >>
|
||||
steps:
|
||||
- checkout
|
||||
- *restore-cache
|
||||
- *install-deps
|
||||
- run:
|
||||
name: Lint
|
||||
command: npm run lint
|
||||
command: npm run lint:ci
|
||||
|
||||
integration_tests:
|
||||
working_directory: ~/nest
|
||||
|
||||
@@ -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/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unsafe-function-type': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-empty-object-type': 'off',
|
||||
'@typescript-eslint/no-wrapper-object-types': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.spec.ts', 'integration/**/*.ts'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.spec.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/no-unsafe-function-type': 'off',
|
||||
'@typescript-eslint/no-unused-expressions': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'@typescript-eslint/no-empty-object-type': 'off',
|
||||
'@typescript-eslint/no-wrapper-object-types': 'off',
|
||||
},
|
||||
}
|
||||
]
|
||||
};
|
||||
55
eslint.config.mjs
Normal file
55
eslint.config.mjs
Normal file
@@ -0,0 +1,55 @@
|
||||
// @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,
|
||||
"checksConditionals": false
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/require-await": "off",
|
||||
'@typescript-eslint/prefer-promise-reject-errors': 'off',
|
||||
'@typescript-eslint/no-base-to-string': 'off',
|
||||
'@typescript-eslint/unbound-method': 'off',
|
||||
'@typescript-eslint/only-throw-error': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -4,6 +4,7 @@ import * as chaiAsPromised from 'chai-as-promised';
|
||||
import * as sinon from 'sinon';
|
||||
import { BarService } from '../src/bar.service';
|
||||
import { FooService } from '../src/foo.service';
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
const { expect } = chai;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
@@ -32,7 +33,8 @@
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"e2e/**/*"
|
||||
"e2e/**/*",
|
||||
"test/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -17,17 +17,17 @@ export class WebhooksExplorer {
|
||||
const { name } = this.discoveryService.getMetadataByDecorator(
|
||||
Webhook,
|
||||
wrapper,
|
||||
);
|
||||
)!;
|
||||
return {
|
||||
name,
|
||||
handlers: this.metadataScanner
|
||||
.getAllMethodNames(wrapper.metatype.prototype)
|
||||
.getAllMethodNames(wrapper.metatype!.prototype)
|
||||
.map(methodName => {
|
||||
const { event } = this.discoveryService.getMetadataByDecorator(
|
||||
WebhookHandler,
|
||||
wrapper,
|
||||
methodName,
|
||||
);
|
||||
)!;
|
||||
return {
|
||||
methodName,
|
||||
event,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('GraphQL request scoped', () => {
|
||||
],
|
||||
},
|
||||
})
|
||||
.end((err, res) => {
|
||||
.end(err => {
|
||||
if (err) return end(err);
|
||||
end();
|
||||
});
|
||||
|
||||
@@ -20,6 +20,6 @@ export class CatsRequestScopedService {
|
||||
}
|
||||
|
||||
findOneById(id: number): Cat {
|
||||
return this.cats.find(cat => cat.id === id);
|
||||
return this.cats.find(cat => cat.id === id)!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,6 @@ export class CatsService {
|
||||
}
|
||||
|
||||
findOneById(id: number): Cat {
|
||||
return this.cats.find(cat => cat.id === id);
|
||||
return this.cats.find(cat => cat.id === id)!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ import {
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { expect } from 'chai';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import * as request from 'supertest';
|
||||
import { FastifyRequest } from 'fastify';
|
||||
|
||||
describe('Middleware (FastifyAdapter)', () => {
|
||||
let app: NestFastifyApplication;
|
||||
@@ -398,4 +400,133 @@ describe('Middleware (FastifyAdapter)', () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
|
||||
describe('should have data attached in middleware', () => {
|
||||
@Controller()
|
||||
class DataController {
|
||||
@Get('data')
|
||||
async data(@Req() req: FastifyRequest['raw']) {
|
||||
return {
|
||||
success: true,
|
||||
extras: req?.['raw']?.extras,
|
||||
pong: req?.['raw']?.headers?.ping,
|
||||
};
|
||||
}
|
||||
@Get('pong')
|
||||
async pong(@Req() req: FastifyRequest['raw']) {
|
||||
return { success: true, pong: req?.['raw']?.headers?.ping };
|
||||
}
|
||||
|
||||
@Get('')
|
||||
async rootPath(@Req() req: FastifyRequest['raw']) {
|
||||
return { success: true, root: true };
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
controllers: [DataController],
|
||||
})
|
||||
class DataModule implements NestModule {
|
||||
configure(consumer: MiddlewareConsumer) {
|
||||
consumer
|
||||
.apply((req, res, next) => {
|
||||
req.extras = { data: 'Data attached in middleware' };
|
||||
req.headers['ping'] = 'pong';
|
||||
next();
|
||||
})
|
||||
.forRoutes('*');
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
app = (
|
||||
await Test.createTestingModule({
|
||||
imports: [DataModule],
|
||||
}).compile()
|
||||
).createNestApplication<NestFastifyApplication>(new FastifyAdapter());
|
||||
});
|
||||
|
||||
it(`GET forRoutes('*') with global prefix`, async () => {
|
||||
app.setGlobalPrefix('/api');
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/api/pong',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
pong: 'pong',
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes('*') without prefix config`, async () => {
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
return app
|
||||
.inject({
|
||||
method: 'GET',
|
||||
url: '/pong',
|
||||
})
|
||||
.then(({ payload }) =>
|
||||
expect(payload).to.be.eql(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
pong: 'pong',
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it(`GET forRoutes('*') with global prefix and exclude patterns`, async () => {
|
||||
app.setGlobalPrefix('/api', { exclude: ['/'] });
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200, { success: true, root: true });
|
||||
});
|
||||
|
||||
it(`GET forRoutes('*') with global prefix and global prefix options`, async () => {
|
||||
app.setGlobalPrefix('/api', { exclude: ['/'] });
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.get('/api/data')
|
||||
.expect(200, {
|
||||
success: true,
|
||||
extras: { data: 'Data attached in middleware' },
|
||||
pong: 'pong',
|
||||
});
|
||||
await request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200, { success: true, root: true });
|
||||
});
|
||||
|
||||
it(`GET forRoutes('*') with global prefix that not starts with /`, async () => {
|
||||
app.setGlobalPrefix('api');
|
||||
await app.init();
|
||||
await app.getHttpAdapter().getInstance().ready();
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.get('/api/data')
|
||||
.expect(200, {
|
||||
success: true,
|
||||
extras: { data: 'Data attached in middleware' },
|
||||
pong: 'pong',
|
||||
});
|
||||
await request(app.getHttpServer()).get('/').expect(404);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -39,4 +39,4 @@ async function bootstrap() {
|
||||
process.kill(process.pid, SIGNAL);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -6,7 +6,7 @@ export class CircularModule {
|
||||
const a = {
|
||||
module: CircularModule,
|
||||
providers: [InputService],
|
||||
b: null,
|
||||
b: null as any,
|
||||
};
|
||||
a.b = a;
|
||||
return a;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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();
|
||||
|
||||
41
integration/lazy-modules/tsconfig.json
Normal file
41
integration/lazy-modules/tsconfig.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": 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",
|
||||
]
|
||||
}
|
||||
@@ -100,7 +100,7 @@ describe.skip('Kafka concurrent', function () {
|
||||
}
|
||||
}
|
||||
|
||||
if (topicMetadata && topicMetadata.topics.length > 0) {
|
||||
if (topicMetadata! && topicMetadata.topics.length > 0) {
|
||||
// we have topics, how many partitions do they have?
|
||||
for (const topic of topicMetadata.topics) {
|
||||
if (topic.partitions.length < numbersOfServers) {
|
||||
|
||||
@@ -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)
|
||||
void request(server)
|
||||
.post('/notify')
|
||||
.send()
|
||||
.end(() => {
|
||||
@@ -123,7 +123,7 @@ describe.skip('Kafka transport', function () {
|
||||
});
|
||||
|
||||
it(`/POST (sync command create user) Concurrency Test`, async () => {
|
||||
const promises = [];
|
||||
const promises = [] as Array<Promise<any>>;
|
||||
for (let concurrencyKey = 0; concurrencyKey < 100; concurrencyKey++) {
|
||||
const innerUserDto = JSON.parse(JSON.stringify(userDto));
|
||||
innerUserDto.name += `+${concurrencyKey}`;
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('MQTT transport', () => {
|
||||
}).timeout(5000);
|
||||
|
||||
it(`/POST (event notification)`, done => {
|
||||
request(server)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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)
|
||||
void 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);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ import { SumDto } from './dto/sum.dto';
|
||||
*/
|
||||
const explicitPartitioner = () => {
|
||||
return ({ message }: PartitionerArgs) => {
|
||||
return parseFloat(message.headers.toPartition.toString());
|
||||
return parseFloat(message.headers!.toPartition!.toString());
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -138,7 +138,7 @@ export class MqttController {
|
||||
}
|
||||
|
||||
@MessagePattern('wildcard-message/#')
|
||||
wildcardMessageHandler(data: number[]): number {
|
||||
wildcardMessageHandler(data: number[]): number | undefined {
|
||||
if ((data as any).response) {
|
||||
return;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ export class MqttController {
|
||||
}
|
||||
|
||||
@MessagePattern('$share/test-group/shared-wildcard-message/#')
|
||||
sharedWildcardMessageHandler(data: number[]): number {
|
||||
sharedWildcardMessageHandler(data: number[]): number | undefined {
|
||||
if ((data as any).response) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
@@ -32,7 +33,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();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": true,
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../../packages/common"],
|
||||
"@nestjs/common/*": ["../../../packages/common/*"],
|
||||
@@ -20,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"],
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": true,
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../../packages/common"],
|
||||
"@nestjs/common/*": ["../../../packages/common/*"],
|
||||
@@ -20,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"],
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": true,
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../../packages/common"],
|
||||
"@nestjs/common/*": ["../../../packages/common/*"],
|
||||
@@ -20,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,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 () => {
|
||||
|
||||
41
integration/nest-application/listen/tsconfig.json
Normal file
41
integration/nest-application/listen/tsconfig.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": false,
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"noLib": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": 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/**/*",
|
||||
"e2e/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export class ExpressController {
|
||||
getRawBody(@Req() req: RawBodyRequest<Request>) {
|
||||
return {
|
||||
parsed: req.body,
|
||||
raw: req.rawBody.toString(),
|
||||
raw: req.rawBody!.toString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class FastifyController {
|
||||
getRawBody(@Req() req: RawBodyRequest<FastifyRequest>) {
|
||||
return {
|
||||
parsed: req.body,
|
||||
raw: req.rawBody.toString(),
|
||||
raw: req.rawBody!.toString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"outDir": "./dist",
|
||||
"strictNullChecks": true,
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../../packages/common"],
|
||||
"@nestjs/common/*": ["../../../packages/common/*"],
|
||||
@@ -20,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"],
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ export class DurableContextIdStrategy implements ContextIdStrategy {
|
||||
let tenantSubTreeId: ContextId;
|
||||
|
||||
if (tenants.has(tenantId)) {
|
||||
tenantSubTreeId = tenants.get(tenantId);
|
||||
tenantSubTreeId = tenants.get(tenantId)!;
|
||||
} else {
|
||||
tenantSubTreeId = { id: +tenantId } as ContextId;
|
||||
tenants.set(tenantId, tenantSubTreeId);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Guard implements CanActivate {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
static REQUEST_SCOPED_DATA = [] as number[];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
|
||||
Guard.COUNTER++;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Interceptor implements NestInterceptor {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
static REQUEST_SCOPED_DATA = [] as number[];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
|
||||
Interceptor.COUNTER++;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { UsersService } from './users.service';
|
||||
@Injectable()
|
||||
export class UserByIdPipe implements PipeTransform<string> {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
static REQUEST_SCOPED_DATA = [] as number[];
|
||||
|
||||
constructor(
|
||||
@Inject('REQUEST_ID') private readonly requestId: number,
|
||||
|
||||
@@ -5,4 +5,4 @@ async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
void bootstrap();
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Guard implements CanActivate {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
static REQUEST_SCOPED_DATA = [] as number[];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
|
||||
Guard.COUNTER++;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Observable } from 'rxjs';
|
||||
@Injectable({ scope: Scope.REQUEST })
|
||||
export class Interceptor implements NestInterceptor {
|
||||
static COUNTER = 0;
|
||||
static REQUEST_SCOPED_DATA = [];
|
||||
static REQUEST_SCOPED_DATA = [] as number[];
|
||||
|
||||
constructor(@Inject('REQUEST_ID') private readonly requestId: number) {
|
||||
Interceptor.COUNTER++;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('Custom Versioning (fastify)', () => {
|
||||
.flatMap(v => v.split(','))
|
||||
.map(header => header.match(/v(\d+\.?\d*)\+json$/))
|
||||
.filter(match => match && match.length)
|
||||
.map(matchArray => matchArray[1])
|
||||
.map(matchArray => matchArray![1])
|
||||
.sort()
|
||||
.reverse();
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ describe('Custom Versioning', () => {
|
||||
?.split(',')
|
||||
.map(header => header.match(/v(\d+\.?\d*)\+json$/))
|
||||
.filter(match => match && match.length)
|
||||
.map(matchArray => matchArray[1])
|
||||
.map(matchArray => matchArray![1])
|
||||
.sort()
|
||||
.reverse();
|
||||
|
||||
return versions;
|
||||
return versions!;
|
||||
};
|
||||
let app: INestApplication;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
@@ -11,20 +11,27 @@ describe('ErrorGateway', () => {
|
||||
const testingModule = await Test.createTestingModule({
|
||||
providers: [ErrorGateway],
|
||||
}).compile();
|
||||
app = await testingModule.createNestApplication();
|
||||
|
||||
app = testingModule.createNestApplication();
|
||||
await app.listen(3000);
|
||||
});
|
||||
|
||||
it(`should handle error`, async () => {
|
||||
const ws = io('http://localhost:8080');
|
||||
ws.emit('push', {
|
||||
test: 'test',
|
||||
});
|
||||
const pattern = 'push';
|
||||
const data = { test: 'test' };
|
||||
|
||||
ws.emit(pattern, data);
|
||||
|
||||
await new Promise<void>(resolve =>
|
||||
ws.on('exception', data => {
|
||||
expect(data).to.be.eql({
|
||||
ws.on('exception', error => {
|
||||
expect(error).to.be.eql({
|
||||
status: 'error',
|
||||
message: 'test',
|
||||
cause: {
|
||||
pattern,
|
||||
data,
|
||||
},
|
||||
});
|
||||
resolve();
|
||||
}),
|
||||
|
||||
@@ -10,7 +10,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 +20,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 +39,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 +63,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 +90,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 +115,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 +132,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 +162,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 +179,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 +211,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 +238,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 +266,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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"allowJs": true,
|
||||
"strictNullChecks": true,
|
||||
"outDir": "./dist",
|
||||
"paths": {
|
||||
"@nestjs/common": ["../../packages/common"],
|
||||
|
||||
37159
package-lock.json
generated
37159
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@@ -37,9 +37,10 @@
|
||||
"test:docker:down": "docker-compose -f integration/docker-compose.yml down",
|
||||
"lint": "concurrently 'npm run lint:packages' 'npm run lint:integration' 'npm run lint:spec'",
|
||||
"lint:fix": "concurrently 'npm run lint:packages -- --fix' 'npm run lint:integration -- --fix' 'npm run lint:spec -- --fix'",
|
||||
"lint:integration": "eslint 'integration/*/{,!(node_modules)/**/}/*.ts'",
|
||||
"lint:packages": "eslint 'packages/**/**.ts' --ignore-pattern 'packages/**/*.spec.ts'",
|
||||
"lint:spec": "eslint 'packages/**/**.spec.ts'",
|
||||
"lint:integration": "node --max-old-space-size=4096 ./node_modules/.bin/eslint 'integration/**/*.ts'",
|
||||
"lint:packages": "node --max-old-space-size=4096 ./node_modules/.bin/eslint 'packages/**/**.ts' --ignore-pattern 'packages/**/*.spec.ts'",
|
||||
"lint:spec": "node --max-old-space-size=4096 ./node_modules/.bin/eslint 'packages/**/**.spec.ts'",
|
||||
"lint:ci": "concurrently 'npm run lint:packages' 'npm run lint:spec'",
|
||||
"prerelease": "gulp copy-misc",
|
||||
"publish": "npm run prerelease && npm run build:prod && ./node_modules/.bin/lerna publish --force-publish --access public --exact -m \"chore(@nestjs) publish %s release\"",
|
||||
"prepublishOnly": "npm run changelog | pbcopy",
|
||||
@@ -81,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",
|
||||
@@ -98,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",
|
||||
@@ -106,8 +110,6 @@
|
||||
"@types/sinon": "17.0.3",
|
||||
"@types/supertest": "6.0.2",
|
||||
"@types/ws": "8.5.13",
|
||||
"@typescript-eslint/eslint-plugin": "8.15.0",
|
||||
"@typescript-eslint/parser": "8.15.0",
|
||||
"amqp-connection-manager": "4.1.14",
|
||||
"amqplib": "0.10.5",
|
||||
"artillery": "2.0.21",
|
||||
@@ -127,9 +129,11 @@
|
||||
"eslint": "8.57.1",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"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.3",
|
||||
"graphql-subscriptions": "2.0.0",
|
||||
@@ -170,6 +174,7 @@
|
||||
"ts-node": "10.9.2",
|
||||
"typeorm": "0.3.20",
|
||||
"typescript": "5.6.3",
|
||||
"typescript-eslint": "8.15.0",
|
||||
"wrk": "1.2.1",
|
||||
"ws": "8.18.0"
|
||||
},
|
||||
|
||||
@@ -22,8 +22,8 @@ export function applyDecorators(
|
||||
}
|
||||
(decorator as MethodDecorator | PropertyDecorator)(
|
||||
target,
|
||||
propertyKey,
|
||||
descriptor,
|
||||
propertyKey!,
|
||||
descriptor!,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import { PARAMTYPES_METADATA } from '../../constants';
|
||||
export function flatten<T extends Array<unknown> = any>(
|
||||
arr: T,
|
||||
): T extends Array<infer R> ? R : never {
|
||||
const flat = [].concat(...arr);
|
||||
const flat = ([] as any[]).concat(...arr);
|
||||
return flat.some(Array.isArray) ? flatten(flat) : flat;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -41,10 +41,10 @@ export function Inject(
|
||||
const injectCallHasArguments = arguments.length > 0;
|
||||
|
||||
return (target: object, key: string | symbol | undefined, index?: number) => {
|
||||
let type = token || Reflect.getMetadata('design:type', target, key);
|
||||
let type = token || Reflect.getMetadata('design:type', target, key!);
|
||||
// Try to infer the token in a constructor-based injection
|
||||
if (!type && !injectCallHasArguments) {
|
||||
type = Reflect.getMetadata(PARAMTYPES_METADATA, target, key)?.[index];
|
||||
type = Reflect.getMetadata(PARAMTYPES_METADATA, target, key!)?.[index!];
|
||||
}
|
||||
|
||||
if (!isUndefined(index)) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user