Typescript 🖕
This commit is contained in:
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@ -1,6 +1,5 @@
|
||||
import Router from "./router.js";
|
||||
import Router, { Request, Response, Handler } from "./router.js";
|
||||
import Tpl from "./template.js";
|
||||
import { Request, Response, Handler } from "./types.js";
|
||||
export { Router, Tpl, Request, Response, Handler };
|
||||
export default class Flummpress {
|
||||
private server?;
|
||||
|
24
dist/router.d.ts
vendored
24
dist/router.d.ts
vendored
@ -1,5 +1,27 @@
|
||||
import { IncomingMessage, ServerResponse } from "node:http";
|
||||
import Tpl from "./template.js";
|
||||
import { Handler } from "./types.js";
|
||||
export interface Request extends Omit<IncomingMessage, 'url'> {
|
||||
url: {
|
||||
pathname: string;
|
||||
split: string[];
|
||||
searchParams: URLSearchParams;
|
||||
qs: Record<string, string>;
|
||||
};
|
||||
cookies?: Record<string, string>;
|
||||
params?: Record<string, string>;
|
||||
post?: Record<string, string>;
|
||||
}
|
||||
export interface Response extends ServerResponse {
|
||||
reply: (options: {
|
||||
code?: number;
|
||||
type?: string;
|
||||
body: string;
|
||||
}) => void;
|
||||
json: (body: string, code?: number) => void;
|
||||
html: (body: string, code?: number) => void;
|
||||
redirect: (target: string, code?: number) => void;
|
||||
}
|
||||
export type Handler = (req: Request, res: Response, next?: () => void) => void | Promise<void>;
|
||||
export default class Router {
|
||||
private routes;
|
||||
private tpl?;
|
||||
|
Reference in New Issue
Block a user