Comments (5)
Hey guys, you can do this:
It should autocomplete the params and also can validate the types if you define a jsconfig.json
with checkJs=true
/** @typedef {import('@fastify/type-provider-typebox').TypeBoxTypeProvider} TypeBoxTypeProvider */
import createFastify from 'fastify'
import { TypeBoxValidatorCompiler } from '@fastify/type-provider-typebox'
import { Type } from '@sinclair/typebox'
const fastify = createFastify()
/** @type {ReturnType<typeof fastify.withTypeProvider<TypeBoxTypeProvider>>} */
const api = fastify
.setValidatorCompiler(TypeBoxValidatorCompiler)
.withTypeProvider()
api.get('/', {
schema: {
querystring: Type.Object({
x: Type.String(),
y: Type.String(),
z: Type.String()
})
}
}, (req) => {
const { x } = req.query
})
from fastify-type-provider-typebox.
It seems interesting, would you mind opening a PR with your code?
from fastify-type-provider-typebox.
@Eomm Thanks. Unfortunately, I couldn't make it work. I'd be glad to create an example project if needed.
from fastify-type-provider-typebox.
This is the way forward!!
typescript only as a type checker without compiling the code
I'd love to see fastify play nicely with TS typings in JS too...
from fastify-type-provider-typebox.
Wow!
from fastify-type-provider-typebox.
Related Issues (20)
- Error `forgotten to call 'done'` since version 3.4 HOT 9
- `Type.Void` / `Type.Undefined` throws `FST_ERR_SCH_SERIALIZATION_BUILD` since typebox 0.30.0 HOT 3
- Type error: TypeBoxTypeProvider does not satisfy the constraint FastifyTypeProvider HOT 1
- Reply type check improvement HOT 3
- Impossible to declare TypeboxProvider type HOT 6
- Adding multiple items to the security array of the JSON Schema breaks all the types HOT 13
- FST_ERR_SCH_VALIDATION_BUILD error when using 'header' validation
- Add Support Typebox 0.25.x HOT 6
- Expose all of typebox HOT 7
- Support for responses HOT 2
- Does not type check if withTypeProvider is not fluent HOT 6
- Widen typebox peerDependency to allow 0.26 HOT 7
- Support typebox 0.27.8 HOT 2
- Release 3.1.0 broke type inference on fastify route handler request parameter HOT 18
- string auto convert to number HOT 2
- Mention in Typebox Readme.md under "Ecosystem" HOT 1
- Type.String({ format: "date" }) doesn't work in body validator HOT 7
- Allow providing `references: Types.TSchema[]` to TypeboxCompiler
- incorrect (and potentially broken) dependency resolution error when installing latest via NPM HOT 2
- Is there way to create wrapper function for route handler inferring schema type? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-type-provider-typebox.