Request and Reply
Since Kita uses Fastify under the hood, the request and reply types can be accessed directly using FastifyRequest
and FastifyReply
.
WARNING
Direct interactions with these types are not recommended, as Kita may not be able to infer the input and output types correctly.
Only use them in places where Kita does not provide native support.
ts
import type { FastifyReply, FastifyRequest } from 'fastify';
export function get(request: FastifyRequest, reply: FastifyReply) {
return {
method: `Request method is ${request.method}`,
status: `Reply status is ${reply.statusCode}`
};
}
1
json
{
"components": {
"schemas": {
"GetIndexResponse": {
"additionalProperties": false,
"properties": {
"method": { "type": "string" },
"status": { "type": "string" }
},
"required": ["method", "status"],
"type": "object"
}
}
},
"paths": {
"/": {
"get": {
"operationId": "getIndex",
"responses": {
"2XX": {
"description": "Default Response",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/GetIndexResponse" }
}
}
}
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32