Skip to content

Commit cb13295

Browse files
committed
chore: improve request type
1 parent f97540a commit cb13295

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

types/Http/Request/FormRequest.d.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default class FormRequest {
127127
/**
128128
* Get request headers.
129129
*/
130-
headers(): any;
130+
headers<T = any>(): T;
131131

132132
/**
133133
* Check if header is present.
@@ -152,32 +152,32 @@ export default class FormRequest {
152152
* Get specified header.
153153
* @param {string} header
154154
*/
155-
header(header: string, default$?: any): any;
155+
header<T = any>(header: string, default$?: T): T;
156156

157157
/**
158158
* Get bearer token used to authenticate current request.
159159
*/
160-
bearerToken(): any;
160+
bearerToken(): string | null;
161161

162162
/**
163163
* Get request referer.
164164
*/
165-
referer(): any;
165+
referer(): string | null;
166166

167167
/**
168168
* Get request host.
169169
*/
170-
getHost(): any;
170+
getHost(): string | null;
171171

172172
/**
173173
* Get full request host.
174174
*/
175-
getFullOrigin(): any;
175+
getFullOrigin(): string | null;
176176

177177
/**
178178
* Get request origin.
179179
*/
180-
getOrigin(): any;
180+
getOrigin(): string | null;
181181

182182
/**
183183
* Get request origin protocol.
@@ -187,7 +187,7 @@ export default class FormRequest {
187187
/**
188188
* Get request ip address.
189189
*/
190-
ip(): any;
190+
ip(): string | null;
191191

192192
/**
193193
* Check if path matches.
@@ -205,7 +205,7 @@ export default class FormRequest {
205205
* Get url param.
206206
* @param {string} name
207207
*/
208-
param(name: string): string | number;
208+
param<T = string | number>(name: string): T;
209209

210210
/**
211211
* Get all url params.
@@ -221,7 +221,7 @@ export default class FormRequest {
221221
* Get body input or specified query keys.
222222
* @param {string[]} keys
223223
*/
224-
all(keys?: string[]): any;
224+
all<T = any>(keys?: string[]): T;
225225

226226
/**
227227
* Get specified input from body.
@@ -251,7 +251,7 @@ export default class FormRequest {
251251
* Get specified query.
252252
* @param {string|null} key
253253
*/
254-
query(key?: string | null, default$?: any): string | number;
254+
query<T = string | number>(key?: string | null, default$?: any): T
255255

256256
/**
257257
* Get files.
@@ -302,7 +302,7 @@ export default class FormRequest {
302302
* Get request rules.
303303
* @returns {object}
304304
*/
305-
getRules(): object;
305+
getRules<T = ReturnType<T['rules']>>(): T;
306306

307307
/**
308308
* Get currently authenticated user.
@@ -324,6 +324,7 @@ import type Session from "./Session";
324324
import type Cookies from "./Cookies";
325325
import type { FastifyRequest } from "fastify";
326326
import type { FastifyReply } from "fastify";
327+
import s from "connect-redis";
327328

328329
declare const $__patch__$: unique symbol;
329330
declare const $__init__$: unique symbol;

0 commit comments

Comments
 (0)