This commit is contained in:
Jarred Sumner
2022-04-07 22:39:46 -07:00
parent a3398650b5
commit 14def643f7
3 changed files with 0 additions and 74 deletions

23
types/globals.d.ts vendored
View File

@@ -1,23 +0,0 @@
// bun.js v
declare global {
function addEventListener(
name: "fetch",
callback: (event: FetchEvent) => void
): void;
}
declare global {
export interface FetchEvent {
/** HTTP client metadata. This is not implemented yet, do not use. */
readonly client: undefined;
/** HTTP request */
readonly request: InstanceType<Request>;
/** Render the response in the active HTTP request */
respondWith(response: Response): void;
}
}
export {};

4
types/index.d.ts vendored
View File

@@ -1,4 +0,0 @@
/// <reference no-default-lib="true" />
/// <reference lib="esnext" />
/// <reference types="bun.js/types/globals" />
/// <reference types="bun.js/types/modules" />

47
types/modules.d.ts vendored
View File

@@ -1,47 +0,0 @@
// bun.js v
/** Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with bun.js. */
declare module "bun.js/router" {
/** Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent FetchEvent} to a `Route` from the local filesystem. Returns `null` if there is no match. */
function match(event: FetchEvent): Route | null;
/** Match a `pathname` to a `Route` from the local filesystem. Returns `null` if there is no match. */
function match(pathname: string): Route | null;
/** Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Request} to a `Route` from the local filesystem. Returns `null` if there is no match. */
function match(request: Request): Route | null;
/** Route matched from the filesystem. */
export interface Route {
/** URL path as appears in a web browser's address bar */
readonly pathname: string;
/** Project-relative filesystem path to the route file. */
readonly filepath: string;
readonly kind: "exact" | "dynamic" | "catch-all" | "optional-catch-all";
/**
* Route name
* @example
* `"blog/posts/[id]"`
* `"blog/posts/[id]/[[...slug]]"`
* `"blog"`
*/
readonly name: string;
/**
* Route parameters as a key-value object
*
* @example
* ```js
* console.assert(router.query.id === "123");
* console.assert(router.pathname === "/blog/posts/123");
* console.assert(router.route === "blog/posts/[id]");
* ```
*/
readonly query: Record<string, string | string[]>;
/** Synchronously load & evaluate the file corresponding to the route. Returns the exports of the route. This is similar to `await import(route.filepath)`, except it's synchronous. It is recommended to use this function instead of `import`. */
import(): Object;
}
}