From a1810d813139cf0378cc47e320e945e4f65212d8 Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Tue, 23 Nov 2021 20:01:06 +0100 Subject: [PATCH] fix(platform-cache): import UseCase from @tsed/platform-cache instead of @tsed/common --- docs/docs/cache.md | 15 ++++++++++----- packages/platform/common/src/index.ts | 1 - .../platform-test-utils/src/tests/testCache.ts | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/docs/cache.md b/docs/docs/cache.md index 3f7b0e150e6..8fbf90700e8 100644 --- a/docs/docs/cache.md +++ b/docs/docs/cache.md @@ -76,6 +76,8 @@ export class Server {} To interact with the cache manager instance, inject it to your class using the @@PlatformCache@@ token, as follows: ```typescript +import {PlatformCache} from "@tsed/platform-cache"; + @Injectable() export class MyService { @Inject() @@ -126,7 +128,8 @@ await this.cache.reset(); To enable cache on endpoint, use @@UseCache@@ decorator on a method as follows: ```typescript -import {Controller, UseCache, Get, PathParams} from "@tsed/common"; +import {Controller, Get, PathParams} from "@tsed/common"; +import {UseCache} from "@tsed/platform-cache"; @Controller("/my-path") export class MyController { @@ -159,7 +162,7 @@ Because @@UseCache@@ uses @@PlatformCacheInterceptor@@ and not a middleware, you ```typescript import {Injectable} from "@tsed/di"; -import {UseCache} from "@tsed/common"; +import {UseCache} from "@tsed/platform-cache"; @Injectable() export class MyService { @@ -177,7 +180,7 @@ to the UseCache decorator. Ts.ED will use @@deserialize@@ function based on the ```typescript import {Injectable} from "@tsed/di"; -import {UseCache} from "@tsed/common"; +import {UseCache} from "@tsed/platform-cache"; @Injectable() export class MyService { @@ -218,7 +221,8 @@ import {PlatformContext} from "@tsed/common"; The second way is to use the `key` option with @@UseCache@@ decorator: ```typescript -import {Controller, UseCache, Get, PathParams, PlatformContext} from "@tsed/common"; +import {Controller, Get, PathParams, PlatformContext} from "@tsed/common"; +import {UseCache} from "@tsed/platform-cache"; @Controller("/my-path") export class MyController { @@ -241,7 +245,8 @@ export class MyController { TTL can be defined per endpoint with @@UseCache@@: ```typescript -import {Controller, UseCache, Get, PathParams, PlatformContext} from "@tsed/common"; +import {Controller, Get, PathParams, PlatformContext} from "@tsed/common"; +import {UseCache} from "@tsed/platform-cache"; @Controller("/my-path") export class MyController { diff --git a/packages/platform/common/src/index.ts b/packages/platform/common/src/index.ts index 3fbdf21381a..c662aeaf32a 100644 --- a/packages/platform/common/src/index.ts +++ b/packages/platform/common/src/index.ts @@ -5,7 +5,6 @@ export * from "@tsed/di"; export * from "@tsed/platform-params"; export * from "@tsed/platform-exceptions"; export * from "@tsed/platform-response-filter"; -export * from "@tsed/platform-cache"; export * from "@tsed/platform-middlewares"; export * from "@tsed/components-scan"; export * from "@tsed/platform-log-middleware"; diff --git a/packages/platform/platform-test-utils/src/tests/testCache.ts b/packages/platform/platform-test-utils/src/tests/testCache.ts index 258673f867d..8d936cea0b9 100644 --- a/packages/platform/platform-test-utils/src/tests/testCache.ts +++ b/packages/platform/platform-test-utils/src/tests/testCache.ts @@ -1,5 +1,6 @@ -import {Controller, Get, Head, Inject, PathParams, PlatformCache, PlatformTest, Post, QueryParams, UseCache} from "@tsed/common"; +import {Controller, Get, Head, Inject, PathParams, PlatformTest, Post, QueryParams} from "@tsed/common"; import {Property} from "@tsed/schema"; +import {PlatformCache, UseCache} from "@tsed/platform-cache"; import {expect} from "chai"; import SuperTest from "supertest"; import {PlatformTestOptions} from "../interfaces";