1
0

change interfaces to types

This commit is contained in:
2023-02-02 18:30:03 +01:00
parent 7300e36469
commit 7edfc835fa

View File

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