Compare commits

..

6 Commits

Author SHA1 Message Date
Kamil Myśliwiec
f273041594 test: update unit tests 2024-11-07 12:07:59 +01:00
Kamil Myśliwiec
da8ebded25 fix(microservices): use instance ref to call handler #13473 2024-11-07 12:01:18 +01:00
Kamil Mysliwiec
bc4667c15a Update Readme.md 2024-11-05 14:19:52 +01:00
Kamil Myśliwiec
a544552f72 chore(@nestjs) publish v10.4.7 release 2024-11-05 09:57:20 +01:00
Kamil Mysliwiec
954616da7d Merge pull request #14108 from nestjs/chore/undeprecate-listen-fastify
chore(fastify): undeprecate listen method
2024-11-05 09:49:24 +01:00
Kamil Myśliwiec
c6b95f54a7 chore(fastify): undeprecate listen method 2024-11-05 09:37:22 +01:00
14 changed files with 44 additions and 42 deletions

View File

@@ -94,7 +94,7 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
<td><a href="https://www.mercedes-benz.com/" target="_blank"><img src="https://nestjs.com/img/logos/mercedes-logo.png" width="100" valign="middle" /></a></td>
<td><a href="https://www.dinii.jp/" target="_blank"><img src="https://nestjs.com/img/logos/dinii-logo.png" width="65" valign="middle" /></a></td>
<td><a href="https://bloodycase.com/?promocode=NEST" target="_blank"><img src="https://nestjs.com/img/logos/bloodycase-logo.png" width="65" valign="middle" /></a></td>
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/logos/handsontable-logo.svg" width="150" valign="middle" /></a></td>
<td><a href="https://handsontable.com/docs/react-data-grid/?utm_source=NestJS_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024" target="_blank"><img src="https://nestjs.com/img/logos/handsontable-dark-logo.svg#2" width="150" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://www.itflashcards.com/" target="_blank"><img src="https://nestjs.com/img/logos/it_flashcards-logo.png" width="170" valign="middle" /></a></td>
<td align="center" valign="middle"><a href="https://arcjet.com/?ref=nestjs" target="_blank"><img src="https://nestjs.com/img/logos/arcjet-logo.svg" width="170" valign="middle" /></a></td>
</tr>

View File

@@ -3,5 +3,5 @@
"packages": [
"packages/*"
],
"version": "10.4.6"
"version": "10.4.7"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/common",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@common)",
"author": "Kamil Mysliwiec",
"homepage": "https://nestjs.com",

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/core",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@core)",
"author": "Kamil Mysliwiec",
"license": "MIT",
@@ -36,7 +36,7 @@
"uid": "2.0.2"
},
"devDependencies": {
"@nestjs/common": "10.4.6"
"@nestjs/common": "10.4.7"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0",

View File

@@ -39,25 +39,36 @@ export class ListenerMetadataExplorer {
const instancePrototype = Object.getPrototypeOf(instance);
return this.metadataScanner
.getAllMethodNames(instancePrototype)
.map(method => this.exploreMethodMetadata(instancePrototype, method))
.map(method =>
this.exploreMethodMetadata(instance, instancePrototype, method),
)
.filter(metadata => metadata);
}
public exploreMethodMetadata(
instance: Controller,
instancePrototype: object,
methodKey: string,
): EventOrMessageListenerDefinition {
const targetCallback = instancePrototype[methodKey];
const prototypeCallback = instancePrototype[methodKey];
const handlerType = Reflect.getMetadata(
PATTERN_HANDLER_METADATA,
targetCallback,
prototypeCallback,
);
if (isUndefined(handlerType)) {
return;
}
const patterns = Reflect.getMetadata(PATTERN_METADATA, targetCallback);
const transport = Reflect.getMetadata(TRANSPORT_METADATA, targetCallback);
const extras = Reflect.getMetadata(PATTERN_EXTRAS_METADATA, targetCallback);
const patterns = Reflect.getMetadata(PATTERN_METADATA, prototypeCallback);
const transport = Reflect.getMetadata(
TRANSPORT_METADATA,
prototypeCallback,
);
const extras = Reflect.getMetadata(
PATTERN_EXTRAS_METADATA,
prototypeCallback,
);
const targetCallback = instance[methodKey];
return {
methodKey,
targetCallback,

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/microservices",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)",
"author": "Kamil Mysliwiec",
"license": "MIT",
@@ -22,8 +22,8 @@
"tslib": "2.7.0"
},
"devDependencies": {
"@nestjs/common": "10.4.6",
"@nestjs/core": "10.4.6"
"@nestjs/common": "10.4.7",
"@nestjs/core": "10.4.7"
},
"peerDependencies": {
"@grpc/grpc-js": "*",

View File

@@ -71,6 +71,7 @@ describe('ListenerMetadataExplorer', () => {
});
it(`should return undefined when "handlerType" metadata is undefined`, () => {
const metadata = instance.exploreMethodMetadata(
test,
Object.getPrototypeOf(test),
'noPattern',
);
@@ -80,6 +81,7 @@ describe('ListenerMetadataExplorer', () => {
describe('@MessagePattern', () => {
it(`should return pattern properties when "handlerType" metadata is not undefined`, () => {
const metadata = instance.exploreMethodMetadata(
test,
Object.getPrototypeOf(test),
'testMessage',
);
@@ -96,6 +98,7 @@ describe('ListenerMetadataExplorer', () => {
});
it(`should return multiple patterns when more than one is declared`, () => {
const metadata = instance.exploreMethodMetadata(
test,
Object.getPrototypeOf(test),
'testMultipleMessage',
);
@@ -116,6 +119,7 @@ describe('ListenerMetadataExplorer', () => {
describe('@EventPattern', () => {
it(`should return pattern properties when "handlerType" metadata is not undefined`, () => {
const metadata = instance.exploreMethodMetadata(
test,
Object.getPrototypeOf(test),
'testEvent',
);
@@ -132,6 +136,7 @@ describe('ListenerMetadataExplorer', () => {
});
it(`should return multiple patterns when more than one is declared`, () => {
const metadata = instance.exploreMethodMetadata(
test,
Object.getPrototypeOf(test),
'testMultipleEvent',
);

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/platform-express",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@platform-express)",
"author": "Kamil Mysliwiec",
"license": "MIT",
@@ -25,8 +25,8 @@
"tslib": "2.7.0"
},
"devDependencies": {
"@nestjs/common": "10.4.6",
"@nestjs/core": "10.4.6"
"@nestjs/common": "10.4.7",
"@nestjs/core": "10.4.7"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0",

View File

@@ -1,4 +1,4 @@
import { INestApplication, HttpServer } from '@nestjs/common';
import { HttpServer, INestApplication } from '@nestjs/common';
import {
FastifyBodyParser,
FastifyInstance,
@@ -7,14 +7,14 @@ import {
FastifyPluginCallback,
FastifyPluginOptions,
FastifyRegisterOptions,
FastifyRequest,
FastifyReply,
FastifyRequest,
RawServerBase,
RawServerDefault,
} from 'fastify';
import {
Chain as LightMyRequestChain,
InjectOptions,
Chain as LightMyRequestChain,
Response as LightMyRequestResponse,
} from 'light-my-request';
import { FastifyStaticOptions, FastifyViewOptions } from './external';
@@ -98,33 +98,19 @@ export interface NestFastifyApplication<
opts: FastifyListenOptions,
callback?: (err: Error | null, address: string) => void,
): Promise<TServer>;
listen(
opts?: FastifyListenOptions,
): Promise<TServer>;
listen(opts?: FastifyListenOptions): Promise<TServer>;
listen(
callback?: (err: Error | null, address: string) => void,
): Promise<TServer>;
/**
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
* @see https://github.com/fastify/fastify/pull/3712
*/
listen(
port: number | string,
callback?: (err: Error | null, address: string) => void,
): Promise<TServer>;
/**
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
* @see https://github.com/fastify/fastify/pull/3712
*/
listen(
port: number | string,
address: string,
callback?: (err: Error | null, address: string) => void,
): Promise<TServer>;
/**
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
* @see https://github.com/fastify/fastify/pull/3712
*/
listen(
port: number | string,
address: string,

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/platform-fastify",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@platform-fastify)",
"author": "Kamil Mysliwiec",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/platform-socket.io",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@platform-socket.io)",
"author": "Kamil Mysliwiec",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/platform-ws",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@platform-ws)",
"author": "Kamil Mysliwiec",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/testing",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@testing)",
"author": "Kamil Mysliwiec",
"license": "MIT",

View File

@@ -1,6 +1,6 @@
{
"name": "@nestjs/websockets",
"version": "10.4.6",
"version": "10.4.7",
"description": "Nest - modern, fast, powerful node.js web framework (@websockets)",
"author": "Kamil Mysliwiec",
"license": "MIT",
@@ -18,8 +18,8 @@
"tslib": "2.7.0"
},
"devDependencies": {
"@nestjs/common": "10.4.6",
"@nestjs/core": "10.4.6"
"@nestjs/common": "10.4.7",
"@nestjs/core": "10.4.7"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0",