diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 7dc863b1367..d3e15e252e1 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -7,7 +7,7 @@ import team from "../team.json"; // https://vitepress.dev/reference/site-config export default defineConfig({ - title: "Ts.ED a modern Node.js/Bun.js framework built with TypeScript", + title: "Ts.ED a modern Node.js/Bun.js framework built with TypeScript on top of Express.js/Koa.js", lastUpdated: true, description: "Ts.ED offers a flexible and easy-to-learn structure designed to enhance the developer experience. It provides decorators, guidelines, and supports Node.js, Bun.js, Express, Koa, CLI, and serverless architectures (e.g., AWS).", sitemap: { @@ -24,7 +24,7 @@ export default defineConfig({ ["meta", {name: "theme-color", content: "#5f67ee"}], ["meta", {property: "og:type", content: "website"}], ["meta", {property: "og:locale", content: "en"}], - ["meta", {property: "og:title", content: "Ts.ED - A Node.js and TypeScript Framework on top of Express/Koa.js."}], + ["meta", {property: "og:title", content: "Ts.ED a modern Node.js/Bun.js framework built with TypeScript on top of Express.js/Koa.js"}], ["meta", {property: "og:site_name", content: "Ts.ED"}], ["meta", {property: "og:image", content: "https://tsed.dev/tsed-og.png"}], ["meta", {property: "og:url", content: "https://tsed.dev/"}], diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 709efac8d62..1d929a6b322 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -152,7 +152,7 @@ It is also possible to split the configuration by using the @@Module@@: - type: `string[]` -List of glob pattern to scan directories which contains [Services](/docs/prodivers) +List of glob pattern to scan directories which contains [Services](/docs/providers) or [Middlewares](/docs/middlewares). ### middlewares @@ -426,7 +426,7 @@ export class Server {} The configuration can be reused throughout your application in different ways. - With dependency injection in [Controller](/docs/controllers), [Middleware](/docs/middlewares) - , [Pipe](/docs/pipes) or any [Injectable](/docs/services) services. + , [Pipe](/docs/pipes) or any [Injectable](/docs/providers) services. - With the decorators @@Constant@@ and @@Value@@. ### From service (DI) diff --git a/docs/docs/snippets/request-context/fn/request-context-usage.spec.ts b/docs/docs/snippets/request-context/fn/request-context-usage.spec.ts new file mode 100644 index 00000000000..71e0165055c --- /dev/null +++ b/docs/docs/snippets/request-context/fn/request-context-usage.spec.ts @@ -0,0 +1,26 @@ +import {inject, runInContext} from "@tsed/di"; +import {PlatformTest} from "@tsed/platform-http/testing"; +import {CustomRepository} from "./CustomRepository"; + +describe("CustomRepository", () => { + beforeEach(() => PlatformTest.create()); + afterEach(() => PlatformTest.reset()); + + it("should run method with the ctx", async () => { + const ctx = PlatformTest.createRequestContext(); + const service = inject(CustomRepository); + + ctx.request.headers = { + "x-api": "api" + }; + + const result = await runInContext(ctx, () => service.findById("id")); + + expect(result).toEqual({ + id: "id", + headers: { + "x-api": "api" + } + }); + }); +}); diff --git a/docs/docs/snippets/request-context/testing/request-context-usage.spec.ts b/docs/docs/snippets/request-context/testing/request-context-usage.spec.ts index 71e0165055c..411e3a49fde 100644 --- a/docs/docs/snippets/request-context/testing/request-context-usage.spec.ts +++ b/docs/docs/snippets/request-context/testing/request-context-usage.spec.ts @@ -8,7 +8,7 @@ describe("CustomRepository", () => { it("should run method with the ctx", async () => { const ctx = PlatformTest.createRequestContext(); - const service = inject(CustomRepository); + const service = await PlatformTest.invoke(CustomRepository, []); ctx.request.headers = { "x-api": "api" diff --git a/docs/docs/testing.md b/docs/docs/testing.md index 4c3a929e006..360395cf64c 100644 --- a/docs/docs/testing.md +++ b/docs/docs/testing.md @@ -68,7 +68,10 @@ Here is an example of context usage: To run a method with context in your unit test, you can use the @@runInContext@@ function: -<<< @/docs/snippets/request-context/testing/request-context-usage.spec.ts +::: code-group +<<< @/docs/snippets/request-context/fn/request-context-usage.ts [v7/v8] +<<< @/docs/snippets/request-context/testing/request-context-usage.spec.ts [v8+] +::: ## Mock dependencies diff --git a/docs/index.md b/docs/index.md index 79c41eb27f8..6e4748ca576 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ layout: home head: - - meta - name: description - content: Ts.ED is a modern Node.js framework built with TypeScript. It offers a flexible structure with a fast learning curve, specifically designed to improve the developer experience. Ts.ED provides numerous decorators and guidelines to make your code more readable and less error-prone. It supports various platforms and tools, including Node.js/Bun.js, Express.js/Koa.js, CLI, and serverless architectures (e.g., AWS). + content: Ts.ED is a modern Bun.js/Node.js framework built with TypeScript on top of Express.js/Koa.js. It offers a flexible structure with a fast learning curve, specifically designed to improve the developer experience. Ts.ED provides numerous decorators and guidelines to make your code more readable and less error-prone. It supports various platforms and tools, including Node.js/Bun.js, Express.js/Koa.js, CLI, and serverless architectures (e.g., AWS). - - meta - name: keywords content: ts.ed framework express koa aws cli di rest graphql typescript node.js bun.js javascript native ESM decorators jsonschema class models providers pipes middlewares testing developer @@ -12,7 +12,7 @@ head: hero: name: "Ts.ED" text: "A modern framework written in TypeScript" - tagline: "A flexible framework with a fast learning curve, designed to enhance the developer experience" + tagline: "A flexible framework on top of Express.js/Koa.js with a fast learning curve, designed to enhance the developer experience" actions: - theme: brand text: What is Ts.ED? diff --git a/docs/tutorials/snippets/scalar/configuration.ts b/docs/tutorials/snippets/scalar/configuration.ts index 7b5ef234354..0ab003484bd 100644 --- a/docs/tutorials/snippets/scalar/configuration.ts +++ b/docs/tutorials/snippets/scalar/configuration.ts @@ -1,5 +1,5 @@ import "@tsed/platform-express"; -import "@tsed/scalar"; // import swagger Ts.ED module +import "@tsed/scalar"; // import scalar Ts.ED module import {Configuration} from "@tsed/di"; diff --git a/packages/specs/scalar/readme.md b/packages/specs/scalar/readme.md index 81768ecfa75..a2cbf9ee4cd 100644 --- a/packages/specs/scalar/readme.md +++ b/packages/specs/scalar/readme.md @@ -81,7 +81,7 @@ It also possible to create several swagger documentations with `doc` option: ```typescript import {Configuration} from "@tsed/di"; -import "@tsed/scalar"; // import swagger Ts.ED module +import "@tsed/scalar"; // import scalar Ts.ED module @Configuration({ scalar: [ @@ -102,7 +102,7 @@ Then use `@Docs` decorators on your controllers to specify where the controllers ```typescript import {Controller} from "@tsed/di"; -import {Docs} from "@tsed/swagger"; +import {Docs} from "@tsed/scalar"; @Controller("/calendars") @Docs("api-v2") // display this controllers only for api-docs-v2