Skip to content

Commit

Permalink
docs: fix typo in testing and update configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Dec 17, 2024
1 parent 1555e20 commit 474e2d8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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/"}],
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion docs/docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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

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?
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/snippets/scalar/configuration.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
4 changes: 2 additions & 2 deletions packages/specs/scalar/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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
Expand Down

0 comments on commit 474e2d8

Please sign in to comment.