fastify-ata 0.2.10 → 0.2.12
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 +42 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# fastify-ata
|
|
2
2
|
|
|
3
|
-
Fastify plugin for [ata-validator](https://ata-validator.com)
|
|
3
|
+
Fastify plugin for [ata-validator](https://ata-validator.com) - JSON Schema validation powered by simdjson.
|
|
4
4
|
|
|
5
5
|
Drop-in replacement for Fastify's default ajv validator. Standard Schema V1 compatible.
|
|
6
6
|
|
|
@@ -49,9 +49,41 @@ fastify.register(fastifyAta, {
|
|
|
49
49
|
})
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
## Standalone Mode (Pre-compiled)
|
|
53
|
+
|
|
54
|
+
Drop-in replacement for `@fastify/ajv-compiler/standalone`. Same API.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const StandaloneValidator = require('fastify-ata/standalone')
|
|
58
|
+
|
|
59
|
+
// Build phase (once) - compile schemas to JS files
|
|
60
|
+
const app = fastify({
|
|
61
|
+
schemaController: { compilersFactory: {
|
|
62
|
+
buildValidator: StandaloneValidator({
|
|
63
|
+
readMode: false,
|
|
64
|
+
storeFunction(routeOpts, code) {
|
|
65
|
+
fs.writeFileSync(generateFileName(routeOpts), code)
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
}}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Read phase (every startup) - load pre-compiled, near-zero compile time
|
|
72
|
+
const app = fastify({
|
|
73
|
+
schemaController: { compilersFactory: {
|
|
74
|
+
buildValidator: StandaloneValidator({
|
|
75
|
+
readMode: true,
|
|
76
|
+
restoreFunction(routeOpts) {
|
|
77
|
+
return require(generateFileName(routeOpts))
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}}
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
52
84
|
## Standard Schema V1
|
|
53
85
|
|
|
54
|
-
ata-validator natively implements [Standard Schema V1](https://github.com/standard-schema/standard-schema)
|
|
86
|
+
ata-validator natively implements [Standard Schema V1](https://github.com/standard-schema/standard-schema) - the emerging standard for TypeScript-first schema libraries.
|
|
55
87
|
|
|
56
88
|
```js
|
|
57
89
|
const { Validator } = require('ata-validator')
|
|
@@ -91,16 +123,18 @@ Works with Fastify v5's Standard Schema support, tRPC, TanStack Form, Drizzle OR
|
|
|
91
123
|
| **Serverless cold start** (50 schemas) | 7.7ms | 96ms | **12.5x faster** |
|
|
92
124
|
| **ReDoS protection** (catastrophic pattern) | 0.3ms | 765ms | **immune** |
|
|
93
125
|
| **Batch NDJSON** (10K items, multi-core) | 13.4M/sec | 5.1M/sec | **2.6x faster** |
|
|
94
|
-
| **validate(obj)** valid (isolated) |
|
|
95
|
-
| **validate(obj)** invalid (isolated) |
|
|
126
|
+
| **validate(obj)** valid (isolated) | 68M ops/sec | 8M ops/sec | **8.5x faster** |
|
|
127
|
+
| **validate(obj)** invalid (isolated) | 17M ops/sec | 8M ops/sec | **2.1x faster** |
|
|
128
|
+
| **validateJSON(str)** valid | 3.0M ops/sec | 1.9M ops/sec | **1.6x faster** |
|
|
129
|
+
| **Fastify startup** (500 routes) | 46ms | 77ms (standalone) | **1.7x faster** |
|
|
96
130
|
| **Schema compilation** | 113K ops/sec | 818 ops/sec | **138x faster** |
|
|
97
131
|
|
|
98
132
|
### Things only ata can do
|
|
99
133
|
|
|
100
|
-
- **RE2 regex engine**
|
|
101
|
-
- **Multi-core parallel validation**
|
|
102
|
-
- **Standard Schema V1**
|
|
103
|
-
- **138x faster compilation**
|
|
134
|
+
- **RE2 regex engine** - linear-time guaranteed, immune to ReDoS attacks
|
|
135
|
+
- **Multi-core parallel validation** - NDJSON batch at 12.5M items/sec
|
|
136
|
+
- **Standard Schema V1** - native support, ajv doesn't have it
|
|
137
|
+
- **138x faster compilation** - serverless cold starts, dynamic schemas
|
|
104
138
|
|
|
105
139
|
## License
|
|
106
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-ata",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Fastify plugin for ata-validator — beats ajv on every valid-path benchmark. 2.7x faster validate(obj), 151x faster compilation, simdjson + multi-core.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/ata-core/fastify-ata#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"ata-validator": "^0.4.
|
|
29
|
+
"ata-validator": "^0.4.10",
|
|
30
30
|
"fastify-plugin": "^5.1.0",
|
|
31
31
|
"sanitize-filename": "^1.6.4"
|
|
32
32
|
},
|