fossyl 0.1.6 → 0.10.0
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/CLAUDE.md +107 -0
- package/LICENSE +674 -0
- package/README.md +3 -99
- package/bin/fossyl.js +2 -0
- package/dist/index.d.mts +1 -203
- package/dist/index.d.ts +1 -203
- package/dist/index.js +1247 -69
- package/dist/index.mjs +1239 -60
- package/package.json +26 -24
- package/fossyl.svg +0 -2
- package/src/example.ts +0 -31
- package/src/index.ts +0 -22
- package/src/router/router.ts +0 -277
- package/src/router/tmp.sh +0 -15
- package/src/router/types/configuration.types.ts +0 -143
- package/src/router/types/params.types.ts +0 -13
- package/src/router/types/router-creation.types.ts +0 -36
- package/src/router/types/routes.types.ts +0 -124
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { GetEndpointCreationFunction } from "./configuration.types";
|
|
2
|
-
import { EndpointCreationFunction } from "./configuration.types";
|
|
3
|
-
|
|
4
|
-
/* Endpoint seems more complex than it is from its type signature.
|
|
5
|
-
* It has 4 Major functions on offer. The different HTTP methods
|
|
6
|
-
*
|
|
7
|
-
* These use the EndpointCreationFunction
|
|
8
|
-
*/
|
|
9
|
-
export type Endpoint<Path extends string> = {
|
|
10
|
-
get: GetEndpointCreationFunction<Path, "GET">;
|
|
11
|
-
post: EndpointCreationFunction<Path, "POST">;
|
|
12
|
-
put: EndpointCreationFunction<Path, "PUT">;
|
|
13
|
-
delete: GetEndpointCreationFunction<Path, "DELETE">;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates a router that ensures all endpoints extend the route.
|
|
18
|
-
* IDK if this is actually useful, but I kinda like it.
|
|
19
|
-
*
|
|
20
|
-
* There def was a part of me that thought about pure generator functions.
|
|
21
|
-
* In fact... they're provided!
|
|
22
|
-
*
|
|
23
|
-
* We can discuss that.
|
|
24
|
-
*/
|
|
25
|
-
export type Router<BasePath extends string> = {
|
|
26
|
-
/**
|
|
27
|
-
* Creates an endpoint
|
|
28
|
-
* @param path string, must extend Router's string
|
|
29
|
-
*/
|
|
30
|
-
createEndpoint: <Path extends `${BasePath}${string}`>(path: Path) => Endpoint<Path>;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a subrouter
|
|
33
|
-
* @param path string, must extend Router's string
|
|
34
|
-
*/
|
|
35
|
-
createSubrouter: <Path extends `${BasePath}${string}`>(path: Path) => Router<Path>;
|
|
36
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { AuthenticationFunction, ValidatorFunction } from "./configuration.types";
|
|
2
|
-
import { Params } from "./params.types";
|
|
3
|
-
|
|
4
|
-
declare const authBrand: unique symbol;
|
|
5
|
-
export type Authentication = { readonly [authBrand]: "Auth" };
|
|
6
|
-
export function authWrapper<T>(auth: T): T & Authentication {
|
|
7
|
-
return {
|
|
8
|
-
...auth,
|
|
9
|
-
[authBrand]: "Auth",
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type RestMethod = "GET" | "POST" | "PUT" | "DELETE";
|
|
14
|
-
|
|
15
|
-
// Combined Route
|
|
16
|
-
export type BaseRoute<Path extends string> = {
|
|
17
|
-
TRANSACTIONS: boolean;
|
|
18
|
-
path: Path;
|
|
19
|
-
logging?: (input: any) => void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type OpenRoute<
|
|
23
|
-
Path extends string,
|
|
24
|
-
Method extends RestMethod,
|
|
25
|
-
Res extends unknown,
|
|
26
|
-
Query extends unknown | undefined = undefined,
|
|
27
|
-
> = {
|
|
28
|
-
type: "open";
|
|
29
|
-
path: Path;
|
|
30
|
-
method: Method;
|
|
31
|
-
validator?: never;
|
|
32
|
-
authenticator?: never;
|
|
33
|
-
handler: (params: { url: Params<Path>; query: Query }) => Promise<Res>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type AuthenticatedRoute<
|
|
37
|
-
Path extends string,
|
|
38
|
-
Method extends RestMethod,
|
|
39
|
-
Res extends unknown,
|
|
40
|
-
Auth extends Authentication,
|
|
41
|
-
Query extends unknown | undefined = undefined,
|
|
42
|
-
> = {
|
|
43
|
-
type: "authenticated";
|
|
44
|
-
path: Path;
|
|
45
|
-
method: Method;
|
|
46
|
-
validator?: never;
|
|
47
|
-
authenticator: AuthenticationFunction<Auth>;
|
|
48
|
-
handler: (
|
|
49
|
-
params: {
|
|
50
|
-
url: Params<Path>;
|
|
51
|
-
query: Query;
|
|
52
|
-
},
|
|
53
|
-
auth: Auth
|
|
54
|
-
) => Promise<Res>;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ValidatedRoute<
|
|
58
|
-
Path extends string,
|
|
59
|
-
Method extends RestMethod,
|
|
60
|
-
Res extends unknown,
|
|
61
|
-
RequestBody extends unknown,
|
|
62
|
-
Query extends unknown | undefined = undefined,
|
|
63
|
-
> = {
|
|
64
|
-
type: "validated";
|
|
65
|
-
path: Path;
|
|
66
|
-
method: Method;
|
|
67
|
-
validator: ValidatorFunction<RequestBody>;
|
|
68
|
-
authenticator?: never;
|
|
69
|
-
handler: (
|
|
70
|
-
params: {
|
|
71
|
-
url: Params<Path>;
|
|
72
|
-
query: Query;
|
|
73
|
-
},
|
|
74
|
-
body: RequestBody
|
|
75
|
-
) => Promise<Res>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type FullRoute<
|
|
79
|
-
Path extends string,
|
|
80
|
-
Method extends RestMethod,
|
|
81
|
-
Res extends unknown,
|
|
82
|
-
RequestBody extends unknown,
|
|
83
|
-
Auth extends Authentication,
|
|
84
|
-
Query extends unknown | undefined = undefined,
|
|
85
|
-
> = {
|
|
86
|
-
type: "full";
|
|
87
|
-
path: Path;
|
|
88
|
-
method: Method;
|
|
89
|
-
validator: ValidatorFunction<RequestBody>;
|
|
90
|
-
authenticator: AuthenticationFunction<Auth>;
|
|
91
|
-
handler: Query extends undefined
|
|
92
|
-
? (
|
|
93
|
-
params: {
|
|
94
|
-
url: Params<Path>;
|
|
95
|
-
},
|
|
96
|
-
auth: Authentication,
|
|
97
|
-
body: RequestBody
|
|
98
|
-
) => Promise<Res>
|
|
99
|
-
: (
|
|
100
|
-
params: {
|
|
101
|
-
url: Params<Path>;
|
|
102
|
-
query: Query;
|
|
103
|
-
},
|
|
104
|
-
auth: Authentication,
|
|
105
|
-
body: RequestBody
|
|
106
|
-
) => Promise<Res>;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export type Route<
|
|
110
|
-
Path extends string,
|
|
111
|
-
Res extends unknown,
|
|
112
|
-
Method extends RestMethod,
|
|
113
|
-
RequestBody extends unknown | undefined = undefined,
|
|
114
|
-
Auth extends Authentication | undefined = undefined,
|
|
115
|
-
Query extends unknown | undefined = undefined,
|
|
116
|
-
> = [RequestBody, Auth] extends [undefined, undefined]
|
|
117
|
-
? OpenRoute<Path, Method, Res, Query>
|
|
118
|
-
: [RequestBody, Auth] extends [undefined, infer A extends Authentication]
|
|
119
|
-
? AuthenticatedRoute<Path, Method, Res, A, Query>
|
|
120
|
-
: [RequestBody, Auth] extends [infer B, undefined]
|
|
121
|
-
? ValidatedRoute<Path, Method, Res, B, Query>
|
|
122
|
-
: [RequestBody, Auth] extends [infer B, infer A extends Authentication]
|
|
123
|
-
? FullRoute<Path, Method, Res, B, A, Query>
|
|
124
|
-
: never;
|