Skip to content
This repository was archived by the owner on May 6, 2023. It is now read-only.

Commit 54e4fb3

Browse files
committed
updated typings
1 parent dd4643e commit 54e4fb3

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

__tests__/validate-route.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import ValidateRoutes from "../src/utils/ValidateRoutes";
33

44
describe("Path validator tests", () => {
55
it("will make sure the paths point to a module with a default export", async () => {
6-
//Cant actually do this with the current bun testing library?
6+
77
});
88
});

index.d.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
declare type ScanPaths = (path: string, currentLevel: string) => Promise<Array<RoutePath>>
2-
declare type ValidateRoute = (routepath: RoutePath) => Promise<Route> | never;
1+
export declare type ScanPaths = (path: string, currentLevel: string) => Promise<Array<RoutePath>>
2+
export declare type ValidateRoute = (routepath: RoutePath) => Promise<Route> | never;
33

44
declare type RequestMethod = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "HEAD" | "PATCH";
55

6-
declare class BuxtRequest {
7-
constructor(baseRequest: Request);
6+
export declare class BuxtRequest {
7+
constructor(baseRequest: Request, paramData: Route | null);
88

99
request: Request;
1010
method: string;
1111
path: string;
1212
matchPath: string;
13+
folderPath: string;
1314

1415
query: { [key: string]: string };
1516
headers: { [key: string]: string };
1617
params: { [key: string]: string };
18+
rotueParams: { [key: string]: string};
1719

1820
body: any;
1921
blob: any;
@@ -44,10 +46,11 @@ export declare class BuxtServer {
4446
routes: string[];
4547
port: number;
4648
baseAddress: string;
49+
routeRoot: string;
4750

48-
private constructor(port: number);
51+
private constructor(port: number, routeRoot: string);
4952

50-
static createServer(): Promise<BuxtServer>;
53+
static createServer(port: number, routeRoot: string): Promise<BuxtServer>;
5154

5255
private registerRoutes(): Promise<void>;
5356
private handleRequest(): Promise<Response> | Response;
@@ -63,6 +66,12 @@ export declare type RoutePath = {
6366

6467
export declare type Route = {
6568
route: string,
66-
parameters: string[],
69+
routeParameters: RouteParameters,
6770
delegate: (req: BuxtRequest, res: BuxtResponse) => Promise<BuxtResponse>;
68-
}
71+
}
72+
73+
export declare type RouteParameters = {
74+
[key: string]: string
75+
}
76+
77+
export default function (port: number): Promise<BuxtServer>;

0 commit comments

Comments
 (0)