Skip to content

Commit 470fcf8

Browse files
chore(): resolve merge conflicts
2 parents a86f2ae + 0e16450 commit 470fcf8

97 files changed

Lines changed: 3607 additions & 298712 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integration/hello-world/e2e/fastify-adapter.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ describe('Hello world (fastify adapter)', () => {
6363
});
6464
});
6565

66+
it(`/GET { host: [":tenant.example1.com", ":tenant.example2.com"] } not matched`, () => {
67+
return app
68+
.inject({
69+
method: 'GET',
70+
url: '/host-array',
71+
})
72+
.then(({ payload }) => {
73+
expect(JSON.parse(payload)).to.be.eql({
74+
error: 'Internal Server Error',
75+
message:
76+
'HTTP adapter does not support filtering on hosts: [":tenant.example1.com", ":tenant.example2.com"]',
77+
statusCode: 500,
78+
});
79+
});
80+
});
81+
6682
it(`/GET inject with LightMyRequest chaining API`, () => {
6783
return app
6884
.inject()

integration/hello-world/e2e/hello-world.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ describe('Hello world (default adapter)', () => {
2828
path: '/host',
2929
greeting: 'Host Greeting! tenant=acme',
3030
},
31+
{
32+
host: 'acme.example1.com',
33+
path: '/host-array',
34+
greeting: 'Host Greeting! tenant=acme',
35+
},
36+
{
37+
host: 'acme.example2.com',
38+
path: '/host-array',
39+
greeting: 'Host Greeting! tenant=acme',
40+
},
3141
].forEach(({ host, path, greeting }) => {
3242
describe(`host=${host}`, () => {
3343
describe('/GET', () => {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Module } from '@nestjs/common';
22
import { HelloModule } from './hello/hello.module';
3+
import { HostArrayModule } from './host-array/host-array.module';
34
import { HostModule } from './host/host.module';
45

56
@Module({
6-
imports: [HelloModule, HostModule],
7+
imports: [HelloModule, HostModule, HostArrayModule],
78
})
89
export class ApplicationModule {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
2+
3+
export class TestDto {
4+
@IsString()
5+
@IsNotEmpty()
6+
string: string;
7+
8+
@IsNumber()
9+
number: number;
10+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Controller, Get, Header, HostParam, Param } from '@nestjs/common';
2+
import { Observable, of } from 'rxjs';
3+
import { HostArrayService } from './host-array.service';
4+
import { UserByIdPipe } from './users/user-by-id.pipe';
5+
6+
@Controller({
7+
path: 'host-array',
8+
host: [':tenant.example1.com', ':tenant.example2.com'],
9+
})
10+
export class HostArrayController {
11+
constructor(private readonly hostService: HostArrayService) {}
12+
13+
@Get()
14+
@Header('Authorization', 'Bearer')
15+
greeting(@HostParam('tenant') tenant: string): string {
16+
return `${this.hostService.greeting()} tenant=${tenant}`;
17+
}
18+
19+
@Get('async')
20+
async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> {
21+
return `${await this.hostService.greeting()} tenant=${tenant}`;
22+
}
23+
24+
@Get('stream')
25+
streamGreeting(@HostParam('tenant') tenant: string): Observable<string> {
26+
return of(`${this.hostService.greeting()} tenant=${tenant}`);
27+
}
28+
29+
@Get('local-pipe/:id')
30+
localPipe(
31+
@Param('id', UserByIdPipe)
32+
user: any,
33+
@HostParam('tenant') tenant: string,
34+
): any {
35+
return { ...user, tenant };
36+
}
37+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Module } from '@nestjs/common';
2+
import { HostArrayController } from './host-array.controller';
3+
import { HostArrayService } from './host-array.service';
4+
import { UsersService } from './users/users.service';
5+
6+
@Module({
7+
controllers: [HostArrayController],
8+
providers: [HostArrayService, UsersService],
9+
})
10+
export class HostArrayModule {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class HostArrayService {
5+
greeting(): string {
6+
return 'Host Greeting!';
7+
}
8+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
2+
import { UsersService } from './users.service';
3+
4+
@Injectable()
5+
export class UserByIdPipe implements PipeTransform<string> {
6+
constructor(private readonly usersService: UsersService) {}
7+
8+
transform(value: string, metadata: ArgumentMetadata) {
9+
return this.usersService.findById(value);
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Injectable } from '@nestjs/common';
2+
3+
@Injectable()
4+
export class UsersService {
5+
findById(id: string) {
6+
return { id, host: true };
7+
}
8+
}

integration/microservices/e2e/sum-grpc.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,5 @@ describe('GRPC transport', () => {
113113

114114
after(async () => {
115115
await app.close();
116-
client.close();
117116
});
118117
});

0 commit comments

Comments
 (0)