Skip to content

Commit cd406cd

Browse files
committed
feat: repro for how_to_describe_params
(cherry picked from commit 3f9e9ec)
1 parent b7158f0 commit cd406cd

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

Diff for: .adonisjs/api.ts

+16
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,27 @@
77
import type { MakeTuyauRequest, MakeTuyauResponse } from '@tuyau/utils/types'
88
import type { InferInput } from '@vinejs/vine/types'
99

10+
type ValidatorsHowtodescribeparamsGetHead = {
11+
request: MakeTuyauRequest<InferInput<typeof import('../app/validators/how_to_describe_param.ts')['howToDescribeParams']>>
12+
response: MakeTuyauResponse<import('../app/controllers/validators_controller.ts').default['howToDescribeParams'], true>
13+
}
1014
export interface ApiDefinition {
15+
'validators': {
16+
'how_to_describe_params': {
17+
'$url': {
18+
};
19+
'$get': ValidatorsHowtodescribeparamsGetHead;
20+
'$head': ValidatorsHowtodescribeparamsGetHead;
21+
};
22+
};
1123
}
1224
const routes = [
1325
] as const;
1426
export const api = {
1527
routes,
1628
definition: {} as ApiDefinition
1729
}
30+
declare module '@tuyau/inertia/types' {
31+
type InertiaApi = typeof api
32+
export interface Api extends InertiaApi {}
33+
}

Diff for: app/controllers/validators_controller.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type { HttpContext } from '@adonisjs/core/http'
2+
import { howToDescribeParams } from '#validators/how_to_describe_param'
3+
4+
export default class ValidatorsController {
5+
howToDescribeParams({ request }: HttpContext) {
6+
return request.validateUsing(howToDescribeParams)
7+
}
8+
}

Diff for: app/validators/how_to_describe_param.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import vine from '@vinejs/vine'
2+
3+
export const howToDescribeParams = vine.compile(
4+
vine.object({
5+
/**
6+
* Parsable query
7+
* @example 'foo:bar'
8+
* @example 'baz:>0'
9+
*/
10+
query: vine.string().trim().optional(),
11+
})
12+
)

Diff for: start/routes.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
*/
99

1010
import router from '@adonisjs/core/services/router'
11-
router.on('/').renderInertia('home')
1211

12+
const ValidatorsController = () => import('#controllers/validators_controller')
13+
14+
router.on('/').renderInertia('home')
15+
router.get('/validators/how_to_describe_params', [ValidatorsController, 'howToDescribeParams'])

0 commit comments

Comments
 (0)