Socket
Socket
Sign inDemoInstall

itty-router

Package Overview
Dependencies
0
Maintainers
2
Versions
264
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.11 to 5.0.12-next.0

72

package.json
{
"name": "itty-router",
"version": "5.0.11",
"version": "5.0.12-next.0",
"description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.",
"main": "./index.js",
"module": "./index.mjs",
"types": "./index.d.ts",
"types": "./types.d.ts",
"exports": {

@@ -12,3 +12,3 @@ ".": {

"require": "./index.js",
"types": "./index.d.ts"
"types": "./types.d.ts"
},

@@ -18,3 +18,3 @@ "./AutoRouter": {

"require": "./AutoRouter.js",
"types": "./AutoRouter.d.ts"
"types": "./types.d.ts"
},

@@ -24,3 +24,3 @@ "./cors": {

"require": "./cors.js",
"types": "./cors.d.ts"
"types": "./types.d.ts"
},

@@ -30,3 +30,3 @@ "./createResponse": {

"require": "./createResponse.js",
"types": "./createResponse.d.ts"
"types": "./types.d.ts"
},

@@ -36,3 +36,3 @@ "./error": {

"require": "./error.js",
"types": "./error.d.ts"
"types": "./types.d.ts"
},

@@ -42,3 +42,3 @@ "./html": {

"require": "./html.js",
"types": "./html.d.ts"
"types": "./types.d.ts"
},

@@ -48,3 +48,3 @@ "./IttyRouter": {

"require": "./IttyRouter.js",
"types": "./IttyRouter.d.ts"
"types": "./types.d.ts"
},

@@ -54,3 +54,3 @@ "./jpeg": {

"require": "./jpeg.js",
"types": "./jpeg.d.ts"
"types": "./types.d.ts"
},

@@ -60,3 +60,3 @@ "./json": {

"require": "./json.js",
"types": "./json.d.ts"
"types": "./types.d.ts"
},

@@ -66,3 +66,3 @@ "./png": {

"require": "./png.js",
"types": "./png.d.ts"
"types": "./types.d.ts"
},

@@ -72,3 +72,3 @@ "./Router": {

"require": "./Router.js",
"types": "./Router.d.ts"
"types": "./types.d.ts"
},

@@ -78,3 +78,3 @@ "./status": {

"require": "./status.js",
"types": "./status.d.ts"
"types": "./types.d.ts"
},

@@ -84,3 +84,3 @@ "./StatusError": {

"require": "./StatusError.js",
"types": "./StatusError.d.ts"
"types": "./types.d.ts"
},

@@ -90,3 +90,3 @@ "./text": {

"require": "./text.js",
"types": "./text.d.ts"
"types": "./types.d.ts"
},

@@ -96,3 +96,3 @@ "./webp": {

"require": "./webp.js",
"types": "./webp.d.ts"
"types": "./types.d.ts"
},

@@ -102,3 +102,3 @@ "./websocket": {

"require": "./websocket.js",
"types": "./websocket.d.ts"
"types": "./types.d.ts"
},

@@ -108,3 +108,3 @@ "./withContent": {

"require": "./withContent.js",
"types": "./withContent.d.ts"
"types": "./types.d.ts"
},

@@ -114,3 +114,3 @@ "./withCookies": {

"require": "./withCookies.js",
"types": "./withCookies.d.ts"
"types": "./types.d.ts"
},

@@ -120,3 +120,3 @@ "./withParams": {

"require": "./withParams.js",
"types": "./withParams.d.ts"
"types": "./types.d.ts"
}

@@ -167,38 +167,30 @@ },

"devDependencies": {
"@cloudflare/workers-types": "^4.20240312.0",
"@cloudflare/workers-types": "^4.20240405.0",
"@rollup/plugin-multi-entry": "^6.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@skypack/package-check": "^0.2.2",
"@types/node": "^20.11.27",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-vue": "^5.0.4",
"@vitest/coverage-c8": "^0.33.0",
"@vitest/coverage-v8": "^1.3.1",
"@whatwg-node/server": "^0.9.29",
"@types/node": "^20.12.6",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@vitest/coverage-v8": "^1.4.0",
"@whatwg-node/server": "^0.9.32",
"coveralls": "^3.1.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"fetch-mock": "^9.11.0",
"fs-extra": "^11.2.0",
"globby": "^14.0.1",
"gzip-size": "^7.0.0",
"http": "^0.0.1-security",
"itty-router": "^4.2.0",
"jsdom": "^24.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup": "^4.13.0",
"rollup": "^4.14.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-multi-input": "^1.4.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.2",
"vite": "^5.1.6",
"vitest": "^1.3.1",
"yarn": "^1.22.22",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vitest": "^1.4.0",
"yarn-release": "^1.10.6"
}
}

@@ -1,19 +0,146 @@

export * from './types/AutoRouterOptions';
export * from './types/AutoRouterType';
export * from './types/CustomRoutes';
export * from './types/ErrorHandler';
export * from './types/IRequest';
export * from './types/IRequestStrict';
export * from './types/IttyRouterOptions';
export * from './types/IttyRouterType';
export * from './types/RequestHandler';
export * from './types/ResponseHandler';
export * from './types/RequestLike';
export * from './types/ResponseHandler';
export * from './types/Route';
export * from './types/RouteEntry';
export * from './types/RouterOptions';
export * from './types/RouterType';
export * from './types/HasContent';
export * from './types/ResponseFormatter';
export * from './types/ErrorFormatter';
type GenericTraps = Record<string, any>
type IRequestStrict = {
route: string
params: {
[key: string]: string
}
query: {
[key: string]: string | string[] | undefined
}
proxy?: any
} & Request
type IRequest = IRequestStrict & GenericTraps
type RequestHandler<R = IRequest, Args extends Array<any> = any[]> =
(request: R, ...args: Args) => any
type ResponseHandler<
ResponseType = Response,
RequestType = IRequest,
Args extends any[] = any[]
> = (
response: ResponseType & any,
request: RequestType & any,
...args: Args
) => any
type StatusErrorObject = {
error?: string
[key: string]: any
}
declare class StatusError extends Error {
status: number;
[key: string]: any
constructor(status = 500, body?: StatusErrorObject | string) {
super(typeof body === 'object' ? body.error : body)
typeof body === 'object' && Object.assign(this, body)
this.status = status
}
}
type ErrorHandler<
ErrorType extends Error = StatusError,
RequestType = IRequest, Args extends any[] = any[]
> = (error: ErrorType, request: RequestType, ...args: Args) => any
type RouteEntry = [
httpMethod: string,
match: RegExp,
handlers: RequestHandler[],
path?: string,
]
type IttyRouterOptions = {
base?: string
routes?: RouteEntry[]
} & GenericTraps
type RouterOptions = {
before?: RequestHandler<any>[]
catch?: ErrorHandler
finally?: ResponseHandler[]
} & IttyRouterOptions
type AutoRouterOptions = {
missing?: RequestHandler
format?: ResponseHandler
} & RouterOptions
type RequestLike = {
method: string
url: string
} & GenericTraps
type Route<
R = IRequest,
A extends Array<any> = any[],
> = <
RequestType = R,
Args extends Array<any> = A,
>(
path: string,
...handlers: RequestHandler<RequestType, Args>[]
) => IttyRouterType<R, A>
type CustomRoutes<R = Route> = {
[key: string]: R
}
type IttyRouterType<
R = IRequest,
A extends any[] = any[],
ResponseType = any,
GlobalRequestType = R,
> = {
__proto__: IttyRouterType<R>
routes: RouteEntry[]
fetch: <Args extends any[] = A>(request: RequestLike, ...extra: Args) => Promise<ResponseType>
all: Route<GlobalRequestType, A>
delete: Route<GlobalRequestType, A>
get: Route<GlobalRequestType, A>
head: Route<GlobalRequestType, A>
options: Route<GlobalRequestType, A>
patch: Route<GlobalRequestType, A>
post: Route<GlobalRequestType, A>
put: Route<GlobalRequestType, A>
} & CustomRoutes<Route<GlobalRequestType, A>> & GenericTraps
type RouterType<R = IRequest, Args extends any[] = any[], ResponseType = any> = {
before?: RequestHandler<any>[]
catch?: ErrorHandler
finally?: ResponseHandler[]
} & IttyRouterType<R, Args, ResponseType>
type AutoRouterType<
R = IRequest,
Args extends any[] = any[],
ResponseType = any
> = {
missing?: RequestHandler
format?: ResponseHandler
} & RouterType<R, Args, ResponseType>
type HasContent<ContentType> = {
content: ContentType
} & IRequestStrict
type ResponseFormatter =
(body?: any, options?: ResponseInit) => Response
interface ErrorLike extends Error {
status?: number
[any: string]: any
}
type ErrorBody = string | object
interface ErrorFormatter {
(statusCode?: number, body?: ErrorBody): Response
(error: ErrorLike): Response
}
export type { AutoRouterOptions, AutoRouterType, CustomRoutes, ErrorFormatter, ErrorHandler, HasContent, IRequest, IRequestStrict, IttyRouterOptions, IttyRouterType, RequestHandler, RequestLike, ResponseFormatter, ResponseHandler, Route, RouteEntry, RouterOptions, RouterType };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc