@taserjs/router 0.1.8 → 0.1.10
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/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/define/middleware.cjs.map +1 -1
- package/dist/cjs/define/middleware.d.cts +5 -5
- package/dist/cjs/index.cjs +0 -11
- package/dist/cjs/index.d.cts +3 -3
- package/dist/cjs/middleware/hono-mw.cjs.map +1 -1
- package/dist/cjs/types/index.d.cts +4 -3
- 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/define/middleware.d.ts +5 -5
- package/dist/esm/define/middleware.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/middleware/hono-mw.js.map +1 -1
- package/dist/esm/types/index.d.ts +4 -3
- 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/define/middleware.ts +5 -4
- package/src/index.ts +3 -17
- package/src/middleware/hono-mw.ts +4 -1
- package/src/types/index.ts +16 -8
- 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/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
LayoutBuilder,
|
|
15
15
|
LayoutId,
|
|
16
16
|
LayoutMiddlewaresMap,
|
|
17
|
+
LayoutParams,
|
|
17
18
|
LayoutTree,
|
|
18
19
|
Method,
|
|
19
20
|
MiddlewareBuilder,
|
|
@@ -42,22 +43,7 @@ export type {
|
|
|
42
43
|
export { ValidationError, validationErrorSchema } from "@taserjs/router-utils";
|
|
43
44
|
export type { ResponseValidationFailureHandler, SuccessStatusCode } from "@taserjs/router-utils";
|
|
44
45
|
|
|
45
|
-
export {
|
|
46
|
-
all,
|
|
47
|
-
any,
|
|
48
|
-
del,
|
|
49
|
-
get,
|
|
50
|
-
head,
|
|
51
|
-
layout,
|
|
52
|
-
middleware,
|
|
53
|
-
options,
|
|
54
|
-
patch,
|
|
55
|
-
post,
|
|
56
|
-
put,
|
|
57
|
-
query,
|
|
58
|
-
t,
|
|
59
|
-
type TaserNamespace,
|
|
60
|
-
} from "./builder/standalone.js";
|
|
46
|
+
export { middleware, t, type TaserNamespace } from "./builder/standalone.js";
|
|
61
47
|
|
|
62
48
|
export { createTaserApp, TaserRouter } from "./builder/router.js";
|
|
63
49
|
export { TaserApp } from "./builder/app.js";
|
|
@@ -65,4 +51,4 @@ export { createContext } from "./context/create-context.js";
|
|
|
65
51
|
export { honoMw } from "./middleware/hono-mw.js";
|
|
66
52
|
export type { MiddlewareFn } from "./define/middleware.js";
|
|
67
53
|
|
|
68
|
-
export type { TaserCookieJar, TaserHeaders } from "@taserjs/router-core";
|
|
54
|
+
export type { TaserCookieJar, TaserCookieOptions, TaserHeaders } from "@taserjs/router-core";
|
|
@@ -20,5 +20,8 @@ import type { NextFn } from "../types/units.js";
|
|
|
20
20
|
export function honoMw<TState extends Record<string, unknown> = {}>(
|
|
21
21
|
middleware: MiddlewareHandler,
|
|
22
22
|
): (ctx: unknown, next: NextFn<TState>) => Promise<Response> {
|
|
23
|
-
return createTaserCompatHandler(middleware) as (
|
|
23
|
+
return createTaserCompatHandler(middleware) as (
|
|
24
|
+
ctx: unknown,
|
|
25
|
+
next: NextFn<TState>,
|
|
26
|
+
) => Promise<Response>;
|
|
24
27
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { Awaitable, TaserCookieJar, TaserHeaders } from "@taserjs/router-core";
|
|
2
|
-
import type {
|
|
3
|
-
RouterMiddlewaresRegister,
|
|
4
|
-
RouterRegister,
|
|
5
|
-
RouterRoutesRegister,
|
|
6
|
-
} from "../index.js";
|
|
2
|
+
import type { RouterMiddlewaresRegister, RouterRegister, RouterRoutesRegister } from "../index.js";
|
|
7
3
|
import type {
|
|
8
4
|
MergeMiddlewareField,
|
|
9
5
|
MergeMiddlewareInputField,
|
|
@@ -111,7 +107,9 @@ type ParseParamsFromSegments<S extends string> = S extends `${infer Segment}/${i
|
|
|
111
107
|
|
|
112
108
|
export type PathParams<Path extends string> = Path extends `/${infer Rest}`
|
|
113
109
|
? ParseParamsFromSegments<Rest>
|
|
114
|
-
:
|
|
110
|
+
: ParseParamsFromSegments<Path>;
|
|
111
|
+
|
|
112
|
+
export type LayoutParams<Layout extends string> = PathParams<Layout>;
|
|
115
113
|
|
|
116
114
|
export type ResolveParams<TPathParams, TSchemaParams> =
|
|
117
115
|
TSchemaParams extends Record<string, unknown>
|
|
@@ -517,7 +515,12 @@ export type MiddlewareChainContext<
|
|
|
517
515
|
readonly headers: TaserHeaders;
|
|
518
516
|
readonly cookies: TaserCookieJar;
|
|
519
517
|
query: Simplify<MergePart<TQuery, MiddlewareChainField<Layout, Acc, "query">>>;
|
|
520
|
-
params: Simplify<
|
|
518
|
+
params: Simplify<
|
|
519
|
+
ResolveParams<
|
|
520
|
+
LayoutParams<Layout>,
|
|
521
|
+
Simplify<MergePart<TParams, MiddlewareChainField<Layout, Acc, "params">>>
|
|
522
|
+
>
|
|
523
|
+
>;
|
|
521
524
|
body: Simplify<MergePart<TBody, MiddlewareChainField<Layout, Acc, "body">>>;
|
|
522
525
|
state: Simplify<MiddlewareChainField<Layout, Acc, "state">>;
|
|
523
526
|
}
|
|
@@ -562,7 +565,12 @@ export type MiddlewareBuilder<
|
|
|
562
565
|
readonly headers: TaserHeaders;
|
|
563
566
|
readonly cookies: TaserCookieJar;
|
|
564
567
|
query: Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "query">>>;
|
|
565
|
-
params: Simplify<
|
|
568
|
+
params: Simplify<
|
|
569
|
+
ResolveParams<
|
|
570
|
+
LayoutParams<Layout>,
|
|
571
|
+
Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "params">>>
|
|
572
|
+
>
|
|
573
|
+
>;
|
|
566
574
|
body: Simplify<MergePart<unknown, MiddlewareChainField<Layout, Acc, "body">>>;
|
|
567
575
|
state: Simplify<MiddlewareChainField<Layout, Acc, "state">>;
|
|
568
576
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_route = require("./route.cjs");
|
|
2
|
-
//#region src/builder/factories.ts
|
|
3
|
-
function createWithoutBodyRoute(method) {
|
|
4
|
-
return ((path) => require_route.createRouteBuilder(path, method));
|
|
5
|
-
}
|
|
6
|
-
function createWithBodyRoute(method) {
|
|
7
|
-
return ((path) => require_route.createRouteBuilder(path, method));
|
|
8
|
-
}
|
|
9
|
-
var createGetRoute = createWithoutBodyRoute("GET");
|
|
10
|
-
var createDeleteRoute = createWithoutBodyRoute("DELETE");
|
|
11
|
-
var createOptionsRoute = createWithoutBodyRoute("OPTIONS");
|
|
12
|
-
var createHeadRoute = createWithoutBodyRoute("HEAD");
|
|
13
|
-
var createPostRoute = createWithBodyRoute("POST");
|
|
14
|
-
var createPutRoute = createWithBodyRoute("PUT");
|
|
15
|
-
var createPatchRoute = createWithBodyRoute("PATCH");
|
|
16
|
-
var createQueryRoute = createWithBodyRoute("QUERY");
|
|
17
|
-
var createAnyRoute = ((path, methods) => require_route.createRouteBuilder(path, "ANY", methods));
|
|
18
|
-
var createAllRoute = ((path) => require_route.createRouteBuilder(path, "ALL"));
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.createAllRoute = createAllRoute;
|
|
21
|
-
exports.createAnyRoute = createAnyRoute;
|
|
22
|
-
exports.createDeleteRoute = createDeleteRoute;
|
|
23
|
-
exports.createGetRoute = createGetRoute;
|
|
24
|
-
exports.createHeadRoute = createHeadRoute;
|
|
25
|
-
exports.createOptionsRoute = createOptionsRoute;
|
|
26
|
-
exports.createPatchRoute = createPatchRoute;
|
|
27
|
-
exports.createPostRoute = createPostRoute;
|
|
28
|
-
exports.createPutRoute = createPutRoute;
|
|
29
|
-
exports.createQueryRoute = createQueryRoute;
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=factories.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factories.cjs","names":[],"sources":["../../../src/builder/factories.ts"],"sourcesContent":["import { createRouteBuilder } from \"./route.js\";\nimport type { AppContext, RouteBuilder, RoutePath } from \"../types/index.js\";\nimport type { HttpMethod } from \"../types/units.js\";\n\nexport type CreateWithoutBodyRoute<\n M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = <const Path extends RoutePath>(\n path: Path,\n) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n\nexport type CreateWithBodyRoute<\n M extends \"POST\" | \"PUT\" | \"PATCH\" | \"QUERY\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = <const Path extends RoutePath>(\n path: Path,\n) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n\nexport type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = <\n const Path extends RoutePath,\n const Methods extends readonly HttpMethod[],\n>(\n path: Path,\n methods: Methods,\n) => RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;\n\nexport type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = <\n const Path extends RoutePath,\n>(\n path: Path,\n) => RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;\n\nfunction createWithoutBodyRoute<M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\">(\n method: M,\n): CreateWithoutBodyRoute<M> {\n return ((path: string) =>\n createRouteBuilder(path, method)) as unknown as CreateWithoutBodyRoute<M>;\n}\n\nfunction createWithBodyRoute<M extends \"POST\" | \"PUT\" | \"PATCH\" | \"QUERY\">(\n method: M,\n): CreateWithBodyRoute<M> {\n return ((path: string) => createRouteBuilder(path, method)) as unknown as CreateWithBodyRoute<M>;\n}\n\nexport const createGetRoute = createWithoutBodyRoute(\"GET\");\nexport const createDeleteRoute = createWithoutBodyRoute(\"DELETE\");\nexport const createOptionsRoute = createWithoutBodyRoute(\"OPTIONS\");\nexport const createHeadRoute = createWithoutBodyRoute(\"HEAD\");\nexport const createPostRoute = createWithBodyRoute(\"POST\");\nexport const createPutRoute = createWithBodyRoute(\"PUT\");\nexport const createPatchRoute = createWithBodyRoute(\"PATCH\");\nexport const createQueryRoute = createWithBodyRoute(\"QUERY\");\n\nexport const createAnyRoute: CreateAnyRoute = ((path: string, methods: readonly HttpMethod[]) =>\n createRouteBuilder(path, \"ANY\", methods)) as unknown as CreateAnyRoute;\n\nexport const createAllRoute: CreateAllRoute = ((path: string) =>\n createRouteBuilder(path, \"ALL\")) as unknown as CreateAllRoute;\n"],"mappings":";;AAgCA,SAAS,uBACP,QAC2B;CAC3B,SAAS,SACP,cAAA,mBAAmB,MAAM,MAAM;AACnC;AAEA,SAAS,oBACP,QACwB;CACxB,SAAS,SAAiB,cAAA,mBAAmB,MAAM,MAAM;AAC3D;AAEA,IAAa,iBAAiB,uBAAuB,KAAK;AAC1D,IAAa,oBAAoB,uBAAuB,QAAQ;AAChE,IAAa,qBAAqB,uBAAuB,SAAS;AAClE,IAAa,kBAAkB,uBAAuB,MAAM;AAC5D,IAAa,kBAAkB,oBAAoB,MAAM;AACzD,IAAa,iBAAiB,oBAAoB,KAAK;AACvD,IAAa,mBAAmB,oBAAoB,OAAO;AAC3D,IAAa,mBAAmB,oBAAoB,OAAO;AAE3D,IAAa,mBAAmC,MAAc,YAC5D,cAAA,mBAAmB,MAAM,OAAO,OAAO;AAEzC,IAAa,mBAAmC,SAC9C,cAAA,mBAAmB,MAAM,KAAK"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AppContext, RouteBuilder, RoutePath } from '../types/index.js';
|
|
2
|
-
import { HttpMethod } from '../types/units.js';
|
|
3
|
-
export type CreateWithoutBodyRoute<M extends "GET" | "DELETE" | "OPTIONS" | "HEAD", TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
4
|
-
export type CreateWithBodyRoute<M extends "POST" | "PUT" | "PATCH" | "QUERY", TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
5
|
-
export type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath, const Methods extends readonly HttpMethod[]>(path: Path, methods: Methods) => RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;
|
|
6
|
-
export type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;
|
|
7
|
-
export declare const createGetRoute: CreateWithoutBodyRoute<"GET", import('../types/units.js').EmptyAppContext>;
|
|
8
|
-
export declare const createDeleteRoute: CreateWithoutBodyRoute<"DELETE", import('../types/units.js').EmptyAppContext>;
|
|
9
|
-
export declare const createOptionsRoute: CreateWithoutBodyRoute<"OPTIONS", import('../types/units.js').EmptyAppContext>;
|
|
10
|
-
export declare const createHeadRoute: CreateWithoutBodyRoute<"HEAD", import('../types/units.js').EmptyAppContext>;
|
|
11
|
-
export declare const createPostRoute: CreateWithBodyRoute<"POST", import('../types/units.js').EmptyAppContext>;
|
|
12
|
-
export declare const createPutRoute: CreateWithBodyRoute<"PUT", import('../types/units.js').EmptyAppContext>;
|
|
13
|
-
export declare const createPatchRoute: CreateWithBodyRoute<"PATCH", import('../types/units.js').EmptyAppContext>;
|
|
14
|
-
export declare const createQueryRoute: CreateWithBodyRoute<"QUERY", import('../types/units.js').EmptyAppContext>;
|
|
15
|
-
export declare const createAnyRoute: CreateAnyRoute;
|
|
16
|
-
export declare const createAllRoute: CreateAllRoute;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AppContext, RouteBuilder, RoutePath } from '../types/index.js';
|
|
2
|
-
import { HttpMethod } from '../types/units.js';
|
|
3
|
-
export type CreateWithoutBodyRoute<M extends "GET" | "DELETE" | "OPTIONS" | "HEAD", TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
4
|
-
export type CreateWithBodyRoute<M extends "POST" | "PUT" | "PATCH" | "QUERY", TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;
|
|
5
|
-
export type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath, const Methods extends readonly HttpMethod[]>(path: Path, methods: Methods) => RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;
|
|
6
|
-
export type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = <const Path extends RoutePath>(path: Path) => RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;
|
|
7
|
-
export declare const createGetRoute: CreateWithoutBodyRoute<"GET", import('../index.js').EmptyAppContext>;
|
|
8
|
-
export declare const createDeleteRoute: CreateWithoutBodyRoute<"DELETE", import('../index.js').EmptyAppContext>;
|
|
9
|
-
export declare const createOptionsRoute: CreateWithoutBodyRoute<"OPTIONS", import('../index.js').EmptyAppContext>;
|
|
10
|
-
export declare const createHeadRoute: CreateWithoutBodyRoute<"HEAD", import('../index.js').EmptyAppContext>;
|
|
11
|
-
export declare const createPostRoute: CreateWithBodyRoute<"POST", import('../index.js').EmptyAppContext>;
|
|
12
|
-
export declare const createPutRoute: CreateWithBodyRoute<"PUT", import('../index.js').EmptyAppContext>;
|
|
13
|
-
export declare const createPatchRoute: CreateWithBodyRoute<"PATCH", import('../index.js').EmptyAppContext>;
|
|
14
|
-
export declare const createQueryRoute: CreateWithBodyRoute<"QUERY", import('../index.js').EmptyAppContext>;
|
|
15
|
-
export declare const createAnyRoute: CreateAnyRoute;
|
|
16
|
-
export declare const createAllRoute: CreateAllRoute;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createRouteBuilder } from "./route.js";
|
|
2
|
-
//#region src/builder/factories.ts
|
|
3
|
-
function createWithoutBodyRoute(method) {
|
|
4
|
-
return ((path) => createRouteBuilder(path, method));
|
|
5
|
-
}
|
|
6
|
-
function createWithBodyRoute(method) {
|
|
7
|
-
return ((path) => createRouteBuilder(path, method));
|
|
8
|
-
}
|
|
9
|
-
var createGetRoute = createWithoutBodyRoute("GET");
|
|
10
|
-
var createDeleteRoute = createWithoutBodyRoute("DELETE");
|
|
11
|
-
var createOptionsRoute = createWithoutBodyRoute("OPTIONS");
|
|
12
|
-
var createHeadRoute = createWithoutBodyRoute("HEAD");
|
|
13
|
-
var createPostRoute = createWithBodyRoute("POST");
|
|
14
|
-
var createPutRoute = createWithBodyRoute("PUT");
|
|
15
|
-
var createPatchRoute = createWithBodyRoute("PATCH");
|
|
16
|
-
var createQueryRoute = createWithBodyRoute("QUERY");
|
|
17
|
-
var createAnyRoute = ((path, methods) => createRouteBuilder(path, "ANY", methods));
|
|
18
|
-
var createAllRoute = ((path) => createRouteBuilder(path, "ALL"));
|
|
19
|
-
//#endregion
|
|
20
|
-
export { createAllRoute, createAnyRoute, createDeleteRoute, createGetRoute, createHeadRoute, createOptionsRoute, createPatchRoute, createPostRoute, createPutRoute, createQueryRoute };
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=factories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factories.js","names":[],"sources":["../../../src/builder/factories.ts"],"sourcesContent":["import { createRouteBuilder } from \"./route.js\";\nimport type { AppContext, RouteBuilder, RoutePath } from \"../types/index.js\";\nimport type { HttpMethod } from \"../types/units.js\";\n\nexport type CreateWithoutBodyRoute<\n M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = <const Path extends RoutePath>(\n path: Path,\n) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n\nexport type CreateWithBodyRoute<\n M extends \"POST\" | \"PUT\" | \"PATCH\" | \"QUERY\",\n TAppContext extends Record<string, unknown> = AppContext,\n> = <const Path extends RoutePath>(\n path: Path,\n) => RouteBuilder<Path, M, readonly [], {}, {}, TAppContext>;\n\nexport type CreateAnyRoute<TAppContext extends Record<string, unknown> = AppContext> = <\n const Path extends RoutePath,\n const Methods extends readonly HttpMethod[],\n>(\n path: Path,\n methods: Methods,\n) => RouteBuilder<Path, Methods[number], readonly [], {}, {}, TAppContext>;\n\nexport type CreateAllRoute<TAppContext extends Record<string, unknown> = AppContext> = <\n const Path extends RoutePath,\n>(\n path: Path,\n) => RouteBuilder<Path, HttpMethod, readonly [], {}, {}, TAppContext>;\n\nfunction createWithoutBodyRoute<M extends \"GET\" | \"DELETE\" | \"OPTIONS\" | \"HEAD\">(\n method: M,\n): CreateWithoutBodyRoute<M> {\n return ((path: string) =>\n createRouteBuilder(path, method)) as unknown as CreateWithoutBodyRoute<M>;\n}\n\nfunction createWithBodyRoute<M extends \"POST\" | \"PUT\" | \"PATCH\" | \"QUERY\">(\n method: M,\n): CreateWithBodyRoute<M> {\n return ((path: string) => createRouteBuilder(path, method)) as unknown as CreateWithBodyRoute<M>;\n}\n\nexport const createGetRoute = createWithoutBodyRoute(\"GET\");\nexport const createDeleteRoute = createWithoutBodyRoute(\"DELETE\");\nexport const createOptionsRoute = createWithoutBodyRoute(\"OPTIONS\");\nexport const createHeadRoute = createWithoutBodyRoute(\"HEAD\");\nexport const createPostRoute = createWithBodyRoute(\"POST\");\nexport const createPutRoute = createWithBodyRoute(\"PUT\");\nexport const createPatchRoute = createWithBodyRoute(\"PATCH\");\nexport const createQueryRoute = createWithBodyRoute(\"QUERY\");\n\nexport const createAnyRoute: CreateAnyRoute = ((path: string, methods: readonly HttpMethod[]) =>\n createRouteBuilder(path, \"ANY\", methods)) as unknown as CreateAnyRoute;\n\nexport const createAllRoute: CreateAllRoute = ((path: string) =>\n createRouteBuilder(path, \"ALL\")) as unknown as CreateAllRoute;\n"],"mappings":";;AAgCA,SAAS,uBACP,QAC2B;CAC3B,SAAS,SACP,mBAAmB,MAAM,MAAM;AACnC;AAEA,SAAS,oBACP,QACwB;CACxB,SAAS,SAAiB,mBAAmB,MAAM,MAAM;AAC3D;AAEA,IAAa,iBAAiB,uBAAuB,KAAK;AAC1D,IAAa,oBAAoB,uBAAuB,QAAQ;AAChE,IAAa,qBAAqB,uBAAuB,SAAS;AAClE,IAAa,kBAAkB,uBAAuB,MAAM;AAC5D,IAAa,kBAAkB,oBAAoB,MAAM;AACzD,IAAa,iBAAiB,oBAAoB,KAAK;AACvD,IAAa,mBAAmB,oBAAoB,OAAO;AAC3D,IAAa,mBAAmB,oBAAoB,OAAO;AAE3D,IAAa,mBAAmC,MAAc,YAC5D,mBAAmB,MAAM,OAAO,OAAO;AAEzC,IAAa,mBAAmC,SAC9C,mBAAmB,MAAM,KAAK"}
|
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;
|