hivest-js
Version:
A simple, fast and minimalist framework for Node.js that allows you to create modular applications with dependency injection using decorators
79 lines • 2.23 kB
TypeScript
export type HttpRequest<T = {
[key: string]: any;
}> = T & {
body: T;
query: Record<string, string>;
params: Record<string, string>;
headers: {
Accept?: string;
'Accept-Encoding'?: string;
'Accept-Language'?: string;
'Cache-Control'?: string;
'Content-Type'?: string;
'Content-Length'?: string;
'User-Agent'?: string;
'X-Forwarded-For'?: string;
'X-Forwarded-Host'?: string;
'X-Forwarded-Proto'?: string;
'X-Forwarded-Server'?: string;
'X-Real-IP'?: string;
'X-Request-ID'?: string;
'X-Request-Start'?: string;
'X-Response-Time'?: string;
'X-Runtime'?: string;
'X-UA-Compatible'?: string;
'X-Vercel-IP-City'?: string;
'X-Vercel-IP-Country'?: string;
'X-Vercel-IP-Latitude'?: string;
Authorization?: string;
Cookie?: string;
Host?: string;
Origin?: string;
Referer?: string;
[key: string]: string | undefined;
};
cookies: {
[key: string]: string | undefined;
};
ip: string;
method: string;
path: string;
url: string;
[key: string]: any;
};
export type HttpResponse<T = {
[key: string]: any;
}> = T & {
status: (code: number) => HttpResponse<T>;
headers: (headers: {
[key: string]: string | undefined;
}) => HttpResponse<T>;
send: (body: any) => HttpResponse<T>;
json: (body: any) => HttpResponse;
[key: string]: any;
};
export type HttpNext<T = (err?: any) => void> = T;
export type HttpError<T = {
[key: string]: any;
}> = T & {
status?: number;
message?: string;
[key: string]: any;
};
export interface HttpContext<Req = HttpRequest, Res = HttpResponse, Next = HttpNext, Err = any> {
req: HttpRequest<Req>;
res: HttpResponse<Res>;
next: HttpNext<Next>;
err?: HttpError<Err>;
}
export type EventHandler<T = any> = (data: T) => void | Promise<void>;
export interface EventListenerMetadata {
eventName: string;
handler: EventHandler;
propertyKey: string;
}
export interface EventEmitterMetadata {
eventName: string;
propertyKey: string;
}
//# sourceMappingURL=types.d.ts.map