-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-ws-multi-servers-on-different-paths
- Loading branch information
Showing
195 changed files
with
48,084 additions
and
45,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,6 @@ yarn-error.log | |
/packages/graphql | ||
/benchmarks/memory | ||
build/config\.gypi | ||
|
||
.npmrc | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import * as request from 'supertest'; | ||
import { CustomTtlModule } from '../src/custom-ttl/custom-ttl.module'; | ||
|
||
describe('Caching Custom TTL', () => { | ||
let server; | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const module = await Test.createTestingModule({ | ||
imports: [CustomTtlModule], | ||
}).compile(); | ||
|
||
app = module.createNestApplication(); | ||
server = app.getHttpServer(); | ||
await app.init(); | ||
}); | ||
|
||
it('should return a differnt value after the TTL is elapsed', async () => { | ||
await request(server).get('/').expect(200, '0'); | ||
await new Promise(resolve => setTimeout(resolve, 500)); | ||
await request(server).get('/').expect(200, '1'); | ||
}); | ||
|
||
it('should return the cached value within the TTL', async () => { | ||
await request(server).get('/').expect(200, '0'); | ||
await new Promise(resolve => setTimeout(resolve, 200)); | ||
await request(server).get('/').expect(200, '0'); | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.close(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
CacheInterceptor, | ||
CacheTTL, | ||
Controller, | ||
Get, | ||
UseInterceptors, | ||
} from '@nestjs/common'; | ||
|
||
@Controller() | ||
export class CustomTtlController { | ||
counter = 0; | ||
constructor() {} | ||
|
||
@Get() | ||
@CacheTTL(500) | ||
@UseInterceptors(CacheInterceptor) | ||
getNumber() { | ||
return this.counter++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CacheModule, Module } from '@nestjs/common'; | ||
import { CustomTtlController } from './custom-ttl.controller'; | ||
|
||
@Module({ | ||
imports: [CacheModule.register()], | ||
controllers: [CustomTtlController], | ||
}) | ||
export class CustomTtlModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"declaration": false, | ||
"noImplicitAny": false, | ||
"removeComments": true, | ||
"noLib": false, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"target": "es6", | ||
"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", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ input NewRecipeInput { | |
|
||
type Subscription { | ||
recipeAdded: Recipe! | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { ApplicationModule } from './app.module'; | ||
import { AppModule } from './app.module'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(ApplicationModule); | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(3000); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3166,5 +3166,6 @@ | |
"nodeId": "-2007711503" | ||
} | ||
] | ||
} | ||
}, | ||
"status": "complete" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2624,5 +2624,6 @@ | |
"nodeId": "-2007711503" | ||
} | ||
] | ||
} | ||
}, | ||
"status": "complete" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.