tsoa-next 7.1.0 → 7.3.1
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.
- package/README.MD +87 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -9
- package/tsoa-next-logo-590.png +0 -0
package/README.MD
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
+
<!-- This file is generated from README.template.MD by `npm run sync:readmes`. Do not edit directly. -->
|
|
2
|
+
|
|
1
3
|
<div align="center">
|
|
2
|
-
<a href="https://tsoa-
|
|
3
|
-
<h1>
|
|
4
|
+
<a href="https://tsoa-next.dev/" target="_blank" rel="noreferrer">
|
|
5
|
+
<h1>
|
|
6
|
+
<span style="display: inline-flex; align-items: center; gap: 0.35em; white-space: nowrap;">
|
|
7
|
+
<img src="./tsoa-next-logo-590.png" alt="tsoa-next logo" height="40" style="height: 1em; width: auto;" />
|
|
8
|
+
<span>tsoa-next</span>
|
|
9
|
+
</span>
|
|
10
|
+
</h1>
|
|
4
11
|
</a>
|
|
5
12
|
Pronounced so·uh
|
|
6
13
|
|
|
7
14
|
OpenAPI-compliant REST APIs using TypeScript and Node
|
|
8
15
|
|
|
9
|
-
](https://github.com/tsoa-next/tsoa-next/actions/workflows/runTestsOnPush.yml)
|
|
10
17
|
[](https://www.npmjs.com/package/tsoa-next)
|
|
18
|
+
[](https://sonarcloud.io/summary/new_code?id=tsoa-next_tsoa-next)
|
|
11
19
|
|
|
12
20
|
</div>
|
|
13
21
|
|
|
22
|
+
## Project Lineage
|
|
23
|
+
|
|
24
|
+
`tsoa-next` continues the original [`tsoa`](https://github.com/lukeautry/tsoa) project.
|
|
25
|
+
The original repository and its contributors established the stable TypeScript-first and OpenAPI-first foundation this work builds on.
|
|
26
|
+
Where historical release notes or migration references still point upstream, they are kept intentionally for provenance.
|
|
27
|
+
|
|
14
28
|
## Goal
|
|
15
29
|
|
|
16
30
|
- TypeScript controllers and models as the single source of truth for your API
|
|
@@ -33,25 +47,86 @@ OpenAPI-compliant REST APIs using TypeScript and Node
|
|
|
33
47
|
- Runtime validation of tsoa-next should behave as closely as possible to the specifications that the generated OpenAPI 2/3 schema describes. Any differences in validation logic are clarified by logging warnings during the generation of the OpenAPI Specification (OAS) and/or the routes.
|
|
34
48
|
- Please note that by enabling OpenAPI 3 you minimize the chances of divergent validation logic since OpenAPI 3 has a more expressive schema syntax.
|
|
35
49
|
|
|
50
|
+
## External Validators
|
|
51
|
+
|
|
52
|
+
`@Validate(...)` adds opt-in runtime authority for external schemas on supported controller method parameters.
|
|
53
|
+
|
|
54
|
+
- Supported forms: `@Validate(schema)`, `@Validate('zod', schema)`, `@Validate({ kind: 'zod', schema })`
|
|
55
|
+
- Supported libraries: `zod`, `joi`, `yup`, `superstruct`, `io-ts`
|
|
56
|
+
- `io-ts` installs: add `fp-ts`, and add `io-ts-types` as well if you rely on helpers like `withMessage`
|
|
57
|
+
- Supported parameter decorators: `@Body`, `@BodyProp`, `@Query`, `@Queries`, `@Path`, `@Header`, and `@FormField` / uploaded file params
|
|
58
|
+
- Behavior: TypeScript metadata still drives OpenAPI generation, while the external schema replaces built-in runtime validation for the decorated parameter subtree
|
|
59
|
+
- Compatibility: routes without `@Validate(...)` keep their current behavior
|
|
60
|
+
|
|
61
|
+
Generated `RegisterRoutes(...)` functions also accept an optional validation context so applications can provide translation or failure-formatting hooks:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
RegisterRoutes(app, {
|
|
65
|
+
validation: {
|
|
66
|
+
translate: (key, params) => translateMessage(key, params),
|
|
67
|
+
errorFormatter: failure => failure,
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import * as t from 'io-ts'
|
|
74
|
+
import { withMessage } from 'io-ts-types'
|
|
75
|
+
import { Body, Controller, Post, Route, Validate } from '@tsoa-next/runtime'
|
|
76
|
+
|
|
77
|
+
interface PositiveFloatBrand {
|
|
78
|
+
readonly PositiveFloat: unique symbol
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const PositiveFloat = withMessage(
|
|
82
|
+
t.brand(t.number, (n): n is t.Branded<number, PositiveFloatBrand> => Number.isFinite(n) && n > 0, 'PositiveFloat'),
|
|
83
|
+
() => 'validation.wager.amount.mustBePositiveFloat',
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
const WagerCodec = t.type({
|
|
87
|
+
amount: PositiveFloat,
|
|
88
|
+
outcome: t.Int,
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
type Wager = t.TypeOf<typeof WagerCodec>
|
|
92
|
+
|
|
93
|
+
@Route('wagers')
|
|
94
|
+
export class WagersController extends Controller {
|
|
95
|
+
@Post()
|
|
96
|
+
public createWager(
|
|
97
|
+
@Body()
|
|
98
|
+
@Validate('io-ts', WagerCodec)
|
|
99
|
+
wager: Wager,
|
|
100
|
+
): Wager {
|
|
101
|
+
return wager
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Migration Note
|
|
107
|
+
|
|
108
|
+
This feature is fully opt-in. If you do not use `@Validate(...)`, existing interface/class models, generated routes, validation behavior, and error responses are unchanged.
|
|
109
|
+
|
|
36
110
|
## Getting Started
|
|
37
111
|
|
|
38
112
|
- Requirements:
|
|
39
|
-
- Node.js
|
|
40
|
-
- npm
|
|
41
|
-
-
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
113
|
+
- Node.js 22 or newer
|
|
114
|
+
- npm 10 or newer
|
|
115
|
+
- We verify support across the previous LTS, current LTS, and Node vNext in CI
|
|
116
|
+
- [Documentation](https://tsoa-next.dev/)
|
|
117
|
+
- [API Reference](https://tsoa-next.dev/reference/)
|
|
118
|
+
- [Getting started guide](https://tsoa-next.dev/getting-started)
|
|
44
119
|
|
|
45
120
|
## Examples
|
|
46
121
|
|
|
47
|
-
Check out the [guides](https://tsoa-
|
|
122
|
+
Check out the [guides](https://tsoa-next.dev/)
|
|
48
123
|
|
|
49
|
-
See example controllers in [the tests](tests/fixtures/controllers)
|
|
124
|
+
See example controllers in [the tests](https://github.com/tsoa-next/tsoa-next/tree/main/tests/fixtures/controllers)
|
|
50
125
|
|
|
51
|
-
See example models in [the tests](tests/fixtures/testModel.ts)
|
|
126
|
+
See example models in [the tests](https://github.com/tsoa-next/tsoa-next/blob/main/tests/fixtures/testModel.ts)
|
|
52
127
|
|
|
53
128
|
## Help wanted
|
|
54
129
|
|
|
55
130
|
### Contributing code
|
|
56
131
|
|
|
57
|
-
To contribute (via a PR), please first see the [Contributing Guide](https://github.com/
|
|
132
|
+
To contribute (via a PR), please first see the [Contributing Guide](https://github.com/tsoa-next/tsoa-next/blob/main/docs/CONTRIBUTING.md)
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@tsoa-next/runtime"), exports);
|
|
18
17
|
__exportStar(require("@tsoa-next/cli"), exports);
|
|
18
|
+
__exportStar(require("@tsoa-next/runtime"), exports);
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,qDAAkC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsoa-next",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Build swagger-compliant REST APIs using TypeScript and Node",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"tsoa-next-logo-590.png"
|
|
9
10
|
],
|
|
10
11
|
"bin": {
|
|
11
12
|
"tsoa": "dist/cli.js"
|
|
@@ -28,11 +29,11 @@
|
|
|
28
29
|
"swagger",
|
|
29
30
|
"typescript"
|
|
30
31
|
],
|
|
31
|
-
"author": "
|
|
32
|
+
"author": "Vanna DiCatania <vanna@dicatania.me> (http://www.dicatania.me)",
|
|
32
33
|
"license": "MIT",
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@tsoa-next/cli": "7.1
|
|
35
|
-
"@tsoa-next/runtime": "7.1
|
|
35
|
+
"@tsoa-next/cli": "7.3.1",
|
|
36
|
+
"@tsoa-next/runtime": "7.3.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/node": "24.12.0",
|
|
@@ -40,14 +41,16 @@
|
|
|
40
41
|
},
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/
|
|
44
|
+
"url": "https://github.com/tsoa-next/tsoa-next.git",
|
|
45
|
+
"directory": "packages/tsoa"
|
|
44
46
|
},
|
|
45
47
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
47
|
-
"npm": ">=
|
|
48
|
+
"node": ">=22.0.0",
|
|
49
|
+
"npm": ">=10.0.0"
|
|
48
50
|
},
|
|
49
51
|
"engineStrict": true,
|
|
50
52
|
"publishConfig": {
|
|
51
53
|
"access": "public"
|
|
52
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://tsoa-next.dev"
|
|
53
56
|
}
|
|
Binary file
|