Skip to content

Commit e46147e

Browse files
Merge branch 'master' into fix-ws-multi-servers-on-different-paths
2 parents 081650b + aa2717b commit e46147e

File tree

195 files changed

+48084
-45040
lines changed

Some content is hidden

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

195 files changed

+48084
-45040
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ yarn-error.log
4242
/packages/graphql
4343
/benchmarks/memory
4444
build/config\.gypi
45+
46+
.npmrc
47+
pnpm-lock.yaml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { INestApplication } from '@nestjs/common';
2+
import { Test } from '@nestjs/testing';
3+
import * as request from 'supertest';
4+
import { CustomTtlModule } from '../src/custom-ttl/custom-ttl.module';
5+
6+
describe('Caching Custom TTL', () => {
7+
let server;
8+
let app: INestApplication;
9+
10+
beforeEach(async () => {
11+
const module = await Test.createTestingModule({
12+
imports: [CustomTtlModule],
13+
}).compile();
14+
15+
app = module.createNestApplication();
16+
server = app.getHttpServer();
17+
await app.init();
18+
});
19+
20+
it('should return a differnt value after the TTL is elapsed', async () => {
21+
await request(server).get('/').expect(200, '0');
22+
await new Promise(resolve => setTimeout(resolve, 500));
23+
await request(server).get('/').expect(200, '1');
24+
});
25+
26+
it('should return the cached value within the TTL', async () => {
27+
await request(server).get('/').expect(200, '0');
28+
await new Promise(resolve => setTimeout(resolve, 200));
29+
await request(server).get('/').expect(200, '0');
30+
});
31+
32+
afterEach(async () => {
33+
await app.close();
34+
});
35+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
CacheInterceptor,
3+
CacheTTL,
4+
Controller,
5+
Get,
6+
UseInterceptors,
7+
} from '@nestjs/common';
8+
9+
@Controller()
10+
export class CustomTtlController {
11+
counter = 0;
12+
constructor() {}
13+
14+
@Get()
15+
@CacheTTL(500)
16+
@UseInterceptors(CacheInterceptor)
17+
getNumber() {
18+
return this.counter++;
19+
}
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CacheModule, Module } from '@nestjs/common';
2+
import { CustomTtlController } from './custom-ttl.controller';
3+
4+
@Module({
5+
imports: [CacheModule.register()],
6+
controllers: [CustomTtlController],
7+
})
8+
export class CustomTtlModule {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"declaration": false,
5+
"noImplicitAny": false,
6+
"removeComments": true,
7+
"noLib": false,
8+
"emitDecoratorMetadata": true,
9+
"experimentalDecorators": true,
10+
"target": "es6",
11+
"sourceMap": true,
12+
"allowJs": true,
13+
"outDir": "./dist",
14+
"paths": {
15+
"@nestjs/common": ["../../packages/common"],
16+
"@nestjs/common/*": ["../../packages/common/*"],
17+
"@nestjs/core": ["../../packages/core"],
18+
"@nestjs/core/*": ["../../packages/core/*"],
19+
"@nestjs/microservices": ["../../packages/microservices"],
20+
"@nestjs/microservices/*": ["../../packages/microservices/*"],
21+
"@nestjs/websockets": ["../../packages/websockets"],
22+
"@nestjs/websockets/*": ["../../packages/websockets/*"],
23+
"@nestjs/testing": ["../../packages/testing"],
24+
"@nestjs/testing/*": ["../../packages/testing/*"],
25+
"@nestjs/platform-express": ["../../packages/platform-express"],
26+
"@nestjs/platform-express/*": ["../../packages/platform-express/*"],
27+
"@nestjs/platform-socket.io": ["../../packages/platform-socket.io"],
28+
"@nestjs/platform-socket.io/*": ["../../packages/platform-socket.io/*"],
29+
"@nestjs/platform-ws": ["../../packages/platform-ws"],
30+
"@nestjs/platform-ws/*": ["../../packages/platform-ws/*"]
31+
}
32+
},
33+
"include": [
34+
"src/**/*",
35+
"e2e/**/*"
36+
],
37+
"exclude": [
38+
"node_modules",
39+
]
40+
}

integration/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ services:
2525
- "9001:9001"
2626
restart: always
2727
mysql:
28-
image: mysql:8.0.30
28+
image: mysql:8.0.32
2929
environment:
3030
MYSQL_ROOT_PASSWORD: root
3131
MYSQL_DATABASE: test
@@ -50,7 +50,7 @@ services:
5050
zookeeper:
5151
container_name: test-zookeeper
5252
hostname: zookeeper
53-
image: confluentinc/cp-zookeeper:7.0.1
53+
image: confluentinc/cp-zookeeper:7.3.2
5454
ports:
5555
- "2181:2181"
5656
environment:
@@ -59,7 +59,7 @@ services:
5959
kafka:
6060
container_name: test-kafka
6161
hostname: kafka
62-
image: confluentinc/cp-kafka:7.0.1
62+
image: confluentinc/cp-kafka:7.3.2
6363
depends_on:
6464
- zookeeper
6565
ports:

integration/graphql-code-first/e2e/pipes.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,23 @@ describe('GraphQL Pipes', () => {
3030
errors: [
3131
{
3232
extensions: {
33-
code: 'BAD_USER_INPUT',
34-
response: {
33+
code: 'BAD_REQUEST',
34+
originalError: {
3535
error: 'Bad Request',
3636
message: [
3737
'description must be longer than or equal to 30 characters',
3838
],
3939
statusCode: 400,
4040
},
4141
},
42+
locations: [
43+
{
44+
column: 3,
45+
line: 2,
46+
},
47+
],
4248
message: 'Bad Request Exception',
49+
path: ['addRecipe'],
4350
},
4451
],
4552
});

integration/graphql-code-first/schema.gql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ input NewRecipeInput {
3131

3232
type Subscription {
3333
recipeAdded: Recipe!
34-
}
34+
}

integration/graphql-code-first/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { RecipesModule } from './recipes/recipes.module';
99
RecipesModule,
1010
GraphQLModule.forRoot<ApolloDriverConfig>({
1111
driver: ApolloDriver,
12-
debug: false,
12+
includeStacktraceInErrorResponses: false,
1313
installSubscriptionHandlers: true,
1414
autoSchemaFile: join(
1515
process.cwd(),

integration/graphql-code-first/src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ValidationPipe } from '@nestjs/common';
22
import { NestFactory } from '@nestjs/core';
3-
import { ApplicationModule } from './app.module';
3+
import { AppModule } from './app.module';
44

55
async function bootstrap() {
6-
const app = await NestFactory.create(ApplicationModule);
6+
const app = await NestFactory.create(AppModule);
77
app.useGlobalPipes(new ValidationPipe());
88
await app.listen(3000);
99
}

0 commit comments

Comments
 (0)