diff --git a/src/index.ts b/src/index.ts index 65be050..03dbebe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ * @property {string} url URL String * @property {RouterHandler[]} handlers Array of handler functions */ -export interface Route { +export type Route = { method: string url: string handlers: RouterHandler[] @@ -20,7 +20,7 @@ export interface Route { * @property {RouterRequest} req Request Object * @property {ExecutionContext} ctx Context Object */ -export interface RouterContext { +export type RouterContext = { env: TEnv req: RouterRequest ctx?: ExecutionContext @@ -54,7 +54,7 @@ export type RouterRequest = { * * @typedef RouterRequestParams */ -export interface RouterRequestParams { +export type RouterRequestParams = { [key: string]: string } @@ -63,7 +63,7 @@ export interface RouterRequestParams { * * @typedef RouterRequestQuery */ -export interface RouterRequestQuery { +export type RouterRequestQuery = { [key: string]: string } @@ -74,7 +74,7 @@ export interface RouterRequestQuery { * @param {RouterContext} ctx * @returns {Promise Response | void} */ -export interface RouterHandler { +export type RouterHandler = { (ctx: RouterContext): Promise | Response | void } @@ -88,7 +88,7 @@ export interface RouterHandler { * @property {number} [maxAge=86400] Access-Control-Max-Age (default: `86400`) * @property {number} [optionsSuccessStatus=204] Return status code for OPTIONS request (default: `204`) */ -export interface RouterCorsConfig { +export type RouterCorsConfig = { allowOrigin?: string allowMethods?: string allowHeaders?: string