@toapi/server 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -0
  2. package/package.json +9 -9
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @toapi/server
2
+
3
+ Define fully-typed REST APIs and handle requests on the server — validation, auth, and caching built in. The API definition doubles as the single source of truth for the fully-typed [@toapi/client](https://www.npmjs.com/package/@toapi/client).
4
+
5
+ 📚 [Docs](https://toapi-js.github.io/toapi/server/)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @toapi/server zod
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ // src/api.ts
17
+ import { defineApi, defineHandler, TResponse } from "@toapi/server";
18
+ import { z } from "zod";
19
+
20
+ export const api = defineApi().route("/hello", {
21
+ GET: defineHandler(
22
+ {
23
+ authorize: () => true,
24
+ response: z.object({ message: z.string() }),
25
+ },
26
+ async () => TResponse.json({ message: "Hello, world!" }),
27
+ ),
28
+ });
29
+ ```
30
+
31
+ ```ts
32
+ // src/server.ts
33
+ import { createRequestHandler } from "@toapi/server";
34
+ import { api } from "./api";
35
+
36
+ export const handler = createRequestHandler(api, { basePath: "/api" });
37
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toapi/server",
3
- "version": "1.2.4",
3
+ "version": "1.3.0",
4
4
  "author": {
5
5
  "name": "Michel Smola",
6
6
  "email": "michel.smola@farbenmeer.de"
@@ -20,26 +20,26 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "zod-openapi": "^6.0.0",
24
- "@toapi/common": "^1.2.4"
23
+ "@toapi/common": "^1.3.0",
24
+ "zod-openapi": "^6.0.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "@toapi/cache": "^0.5.1",
27
28
  "@types/node": "^25.0.3",
28
- "vitest": "^4.0.16",
29
- "zod": "^4.0.17",
30
- "@toapi/cache": "^0.5.1"
29
+ "vitest": "^5.0.0",
30
+ "zod": "^4.0.17"
31
31
  },
32
32
  "peerDependencies": {
33
- "typescript": "^5 || ^6.0.0",
33
+ "typescript": "^5 || ^6.0.0 || ^7.0.0",
34
34
  "zod": "^4.0.17"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",
38
- "url": "git+https://github.com/farbenmeer/tapi.git"
38
+ "url": "git+https://github.com/toapi-js/toapi.git"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsc --noEmit false",
42
42
  "release": "pnpm build && pnpm publish --no-git-checks",
43
- "test": "vitest"
43
+ "test": "vitest run"
44
44
  }
45
45
  }