@taserjs/router 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/cjs/builder/middleware-unit.cjs +50 -50
- package/dist/cjs/builder/middleware-unit.cjs.map +1 -1
- package/dist/cjs/builder/middleware-unit.d.cts +34 -1
- package/dist/cjs/builder/middleware.cjs +13 -12
- package/dist/cjs/builder/middleware.cjs.map +1 -1
- package/dist/cjs/builder/normalize.cjs +10 -0
- package/dist/cjs/builder/normalize.cjs.map +1 -0
- package/dist/cjs/builder/normalize.d.cts +2 -0
- package/dist/cjs/builder/route.cjs +63 -67
- package/dist/cjs/builder/route.cjs.map +1 -1
- package/dist/cjs/builder/standalone.cjs +18 -34
- package/dist/cjs/builder/standalone.cjs.map +1 -1
- package/dist/cjs/builder/standalone.d.cts +7 -14
- package/dist/cjs/index.cjs +0 -11
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/middleware/hono-mw.cjs +1 -1
- package/dist/cjs/middleware/hono-mw.cjs.map +1 -1
- package/dist/cjs/middleware/hono-mw.d.cts +1 -1
- package/dist/esm/builder/middleware-unit.d.ts +34 -1
- package/dist/esm/builder/middleware-unit.js +50 -50
- package/dist/esm/builder/middleware-unit.js.map +1 -1
- package/dist/esm/builder/middleware.js +13 -12
- package/dist/esm/builder/middleware.js.map +1 -1
- package/dist/esm/builder/normalize.d.ts +2 -0
- package/dist/esm/builder/normalize.js +10 -0
- package/dist/esm/builder/normalize.js.map +1 -0
- package/dist/esm/builder/route.js +63 -67
- package/dist/esm/builder/route.js.map +1 -1
- package/dist/esm/builder/standalone.d.ts +7 -14
- package/dist/esm/builder/standalone.js +19 -24
- package/dist/esm/builder/standalone.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/middleware/hono-mw.d.ts +1 -1
- package/dist/esm/middleware/hono-mw.js +1 -1
- package/dist/esm/middleware/hono-mw.js.map +1 -1
- package/package.json +3 -3
- package/src/builder/middleware-unit.ts +56 -51
- package/src/builder/middleware.ts +16 -18
- package/src/builder/normalize.ts +13 -0
- package/src/builder/route.ts +81 -82
- package/src/builder/standalone.ts +56 -52
- package/src/index.ts +2 -17
- package/src/middleware/hono-mw.ts +1 -1
- package/dist/cjs/builder/factories.cjs +0 -31
- package/dist/cjs/builder/factories.cjs.map +0 -1
- package/dist/cjs/builder/factories.d.cts +0 -16
- package/dist/esm/builder/factories.d.ts +0 -16
- package/dist/esm/builder/factories.js +0 -22
- package/dist/esm/builder/factories.js.map +0 -1
- package/src/builder/factories.ts +0 -59
package/src/builder/factories.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createRouteBuilder } from "./route.js";
|
|
2
|
-
import type { AppContext, RouteBuilder, RoutePath } from "../types/index.js";
|
|
3
|
-
import type { HttpMethod } from "../types/units.js";
|
|
4
|
-
|
|
5
|
-
export type CreateWithoutBodyRoute<
|
|
6
|
-
M extends "GET" | "DELETE" | "OPTIONS" | "HEAD",
|
|
7
|
-
TAppContext extends Record<string, unknown> = AppContext,
|
|
8
|
-
> = <const Path extends RoutePath>(
|
|
9
|
-
path: Path,
|
|
10
|
-
) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
11
|
-
|
|
12
|
-
export type CreateWithBodyRoute<
|
|
13
|
-
M extends "POST" | "PUT" | "PATCH" | "QUERY",
|
|
14
|
-
TAppContext extends Record<string, unknown> = AppContext,
|
|
15
|
-
> = <const Path extends RoutePath>(
|
|
16
|
-
path: Path,
|
|
17
|
-
) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
18
|
-
|
|
19
|
-
export type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = <
|
|
20
|
-
const Path extends RoutePath,
|
|
21
|
-
const Methods extends readonly HttpMethod[],
|
|
22
|
-
>(
|
|
23
|
-
path: Path,
|
|
24
|
-
methods: Methods,
|
|
25
|
-
) => RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;
|
|
26
|
-
|
|
27
|
-
export type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = <
|
|
28
|
-
const Path extends RoutePath,
|
|
29
|
-
>(
|
|
30
|
-
path: Path,
|
|
31
|
-
) => RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;
|
|
32
|
-
|
|
33
|
-
function createWithoutBodyRoute<M extends "GET" | "DELETE" | "OPTIONS" | "HEAD">(
|
|
34
|
-
method: M,
|
|
35
|
-
): CreateWithoutBodyRoute<M> {
|
|
36
|
-
return ((path: string) =>
|
|
37
|
-
createRouteBuilder(path, method)) as unknown as CreateWithoutBodyRoute<M>;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createWithBodyRoute<M extends "POST" | "PUT" | "PATCH" | "QUERY">(
|
|
41
|
-
method: M,
|
|
42
|
-
): CreateWithBodyRoute<M> {
|
|
43
|
-
return ((path: string) => createRouteBuilder(path, method)) as unknown as CreateWithBodyRoute<M>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const createGetRoute = createWithoutBodyRoute("GET");
|
|
47
|
-
export const createDeleteRoute = createWithoutBodyRoute("DELETE");
|
|
48
|
-
export const createOptionsRoute = createWithoutBodyRoute("OPTIONS");
|
|
49
|
-
export const createHeadRoute = createWithoutBodyRoute("HEAD");
|
|
50
|
-
export const createPostRoute = createWithBodyRoute("POST");
|
|
51
|
-
export const createPutRoute = createWithBodyRoute("PUT");
|
|
52
|
-
export const createPatchRoute = createWithBodyRoute("PATCH");
|
|
53
|
-
export const createQueryRoute = createWithBodyRoute("QUERY");
|
|
54
|
-
|
|
55
|
-
export const createAnyRoute: CreateAnyRoute = ((path: string, methods: readonly HttpMethod[]) =>
|
|
56
|
-
createRouteBuilder(path, "ANY", methods)) as unknown as CreateAnyRoute;
|
|
57
|
-
|
|
58
|
-
export const createAllRoute: CreateAllRoute = ((path: string) =>
|
|
59
|
-
createRouteBuilder(path, "ALL")) as unknown as CreateAllRoute;
|