1
- import { TSchema , TypeGuard } from '@sinclair/typebox' ;
1
+ import { TypeGuard , type TSchema } from '@sinclair/typebox' ;
2
2
import { TypeCompiler , ValueError , ValueErrorIterator } from '@sinclair/typebox/compiler' ;
3
3
import { Value } from '@sinclair/typebox/value' ;
4
4
import { HTTPError } from '@whatwg-node/server' ;
@@ -47,7 +47,7 @@ export function useTypeBox<TServerContext, TComponents extends RouterComponentsB
47
47
}
48
48
return {
49
49
onRouteHandle ( { route : { schemas } , request } ) {
50
- if ( schemas ?. request ?. headers && TypeGuard . TSchema ( schemas . request . headers ) ) {
50
+ if ( schemas ?. request ?. headers && TypeGuard . IsSchema ( schemas . request . headers ) ) {
51
51
const validateFn = getValidateFn ( schemas . request . headers ) ;
52
52
const headersObj = getHeadersObj ( request . headers as any ) ;
53
53
const errors = [ ...validateFn ( headersObj ) ] . map ( error => sanitizeError ( error , 'headers' ) ) ;
@@ -64,7 +64,7 @@ export function useTypeBox<TServerContext, TComponents extends RouterComponentsB
64
64
) ;
65
65
}
66
66
}
67
- if ( schemas ?. request ?. params && TypeGuard . TSchema ( schemas . request . params ) ) {
67
+ if ( schemas ?. request ?. params && TypeGuard . IsSchema ( schemas . request . params ) ) {
68
68
const validateFn = getValidateFn ( schemas . request . params ) ;
69
69
const errors = [ ...validateFn ( request . params ) ] . map ( error => sanitizeError ( error , 'params' ) ) ;
70
70
if ( errors . length ) {
@@ -80,7 +80,7 @@ export function useTypeBox<TServerContext, TComponents extends RouterComponentsB
80
80
) ;
81
81
}
82
82
}
83
- if ( schemas ?. request ?. query && TypeGuard . TSchema ( schemas . request . query ) ) {
83
+ if ( schemas ?. request ?. query && TypeGuard . IsSchema ( schemas . request . query ) ) {
84
84
const validateFn = getValidateFn ( schemas . request . query ) ;
85
85
const errors = [ ...validateFn ( request . query ) ] . map ( error => sanitizeError ( error , 'query' ) ) ;
86
86
if ( errors . length ) {
@@ -96,7 +96,7 @@ export function useTypeBox<TServerContext, TComponents extends RouterComponentsB
96
96
) ;
97
97
}
98
98
}
99
- if ( schemas ?. request ?. json && TypeGuard . TSchema ( schemas . request . json ) ) {
99
+ if ( schemas ?. request ?. json && TypeGuard . IsSchema ( schemas . request . json ) ) {
100
100
const validateFn = getValidateFn ( schemas . request . json ) ;
101
101
const origReqJsonMethod = request . json . bind ( request ) ;
102
102
Object . defineProperty ( request , 'json' , {
@@ -123,7 +123,7 @@ export function useTypeBox<TServerContext, TComponents extends RouterComponentsB
123
123
configurable : true ,
124
124
} ) ;
125
125
}
126
- if ( schemas ?. request ?. formData && TypeGuard . TSchema ( schemas . request . formData ) ) {
126
+ if ( schemas ?. request ?. formData && TypeGuard . IsSchema ( schemas . request . formData ) ) {
127
127
const validateFn = getValidateFn ( schemas . request . formData ) ;
128
128
const origMethod = request . formData . bind ( request ) ;
129
129
Object . defineProperty ( request , 'formData' , {
0 commit comments