@fonderie/core 0.1.4 → 0.1.5
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/brain/signatures.md +152 -0
- package/package.json +5 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<!-- GENERATED — do not edit. Regenerate with: npm run docs:signatures -->
|
|
2
|
+
|
|
3
|
+
# @fonderie/core — signatures
|
|
4
|
+
|
|
5
|
+
## @fonderie/core
|
|
6
|
+
|
|
7
|
+
Subpath exports: `@fonderie/core/config`, `@fonderie/core/types`, `@fonderie/core/middlewares`, `@fonderie/core/parser`, `@fonderie/core/response`
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
interface ITenant {
|
|
11
|
+
id: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
plan: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IRouter {
|
|
17
|
+
match(method: string, path: string): IRouteMatch | null;
|
|
18
|
+
add(method: string, path: string, handler: Middleware): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Operation = 'create' | 'read' | 'update' | 'delete';
|
|
22
|
+
|
|
23
|
+
interface IAuthUser {
|
|
24
|
+
id: string;
|
|
25
|
+
email: string | null;
|
|
26
|
+
phone: string | null;
|
|
27
|
+
suspended: boolean;
|
|
28
|
+
mfaEnabled: boolean;
|
|
29
|
+
deletedAt: Date | null;
|
|
30
|
+
emailVerifiedAt: Date | null;
|
|
31
|
+
loginMethod: 'email' | 'phone' | 'google';
|
|
32
|
+
phoneVerified: boolean;
|
|
33
|
+
mfaPending?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type Middleware = (ctx: IFonderieContext, next: () => Promise<Response>) => Promise<Response>;
|
|
37
|
+
|
|
38
|
+
interface IWorkspace {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
isPersonal?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface IRouteMatch {
|
|
45
|
+
handler: Middleware;
|
|
46
|
+
params: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface IFonderieApp {
|
|
50
|
+
use(middleware: Middleware): IFonderieApp;
|
|
51
|
+
register(module: IFonderieModule): IFonderieApp;
|
|
52
|
+
addRoute(method: string, path: string, ...handlers: Middleware[]): void;
|
|
53
|
+
listen(port: number, options?: {
|
|
54
|
+
name?: string;
|
|
55
|
+
version?: string;
|
|
56
|
+
env?: string;
|
|
57
|
+
}): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface IFonderieModule {
|
|
61
|
+
name: string;
|
|
62
|
+
deps?: string[];
|
|
63
|
+
install(app: IFonderieApp): void | Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface IFonderieContext {
|
|
67
|
+
request: Request;
|
|
68
|
+
meta: IFonderieContextMeta;
|
|
69
|
+
readonly tenant: ITenant | null;
|
|
70
|
+
readonly user: IAuthUser | null;
|
|
71
|
+
readonly workspace: IWorkspace | null;
|
|
72
|
+
_router: IRouter;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface ICourierMessage {
|
|
76
|
+
type: string;
|
|
77
|
+
locale?: string;
|
|
78
|
+
recipient: {
|
|
79
|
+
email: string | null;
|
|
80
|
+
phone: string | null;
|
|
81
|
+
deviceToken: string | null;
|
|
82
|
+
};
|
|
83
|
+
data: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface IFonderieContextMeta {
|
|
87
|
+
params?: Record<string, string>;
|
|
88
|
+
body?: unknown;
|
|
89
|
+
clientIp?: string;
|
|
90
|
+
workspaceId?: string;
|
|
91
|
+
userId?: string;
|
|
92
|
+
userWorkspaceRoles?: string[];
|
|
93
|
+
message?: ICourierMessage;
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const OPERATIONS: { readonly CREATE: "create"; readonly READ: "read"; readonly UPDATE: "update"; readonly DELETE: "delete"; }
|
|
98
|
+
|
|
99
|
+
new FonderieApp(config: FonderieConfig): FonderieApp
|
|
100
|
+
.listen(port: number, options?: { name?: string; version?: string; env?: string; }): void
|
|
101
|
+
.register(module: IFonderieModule): FonderieApp
|
|
102
|
+
.boot(): Promise<FonderieApp>
|
|
103
|
+
.buildContext(request: Request): Promise<IFonderieContext>
|
|
104
|
+
.use(middleware: Middleware): FonderieApp
|
|
105
|
+
.addRoute(method: string, path: string, ...handlers: Middleware[]): void
|
|
106
|
+
.handle(request: Request): Promise<Response>
|
|
107
|
+
|
|
108
|
+
function defineConfig(config: FonderieConfig): FonderieConfig
|
|
109
|
+
|
|
110
|
+
function compose(middlewares: Middleware[]): (ctx: IFonderieContext, fallback: () => Promise<Response>) => Promise<Response>
|
|
111
|
+
|
|
112
|
+
interface FonderieConfig {
|
|
113
|
+
basePath?: string;
|
|
114
|
+
db: {
|
|
115
|
+
url: string;
|
|
116
|
+
};
|
|
117
|
+
billing?: {
|
|
118
|
+
provider: 'stripe';
|
|
119
|
+
plans: IBillingPlan[];
|
|
120
|
+
stripeSecretKey: string;
|
|
121
|
+
};
|
|
122
|
+
email?: {
|
|
123
|
+
from: string;
|
|
124
|
+
apiKey?: string;
|
|
125
|
+
smtp?: ISMTPConfig;
|
|
126
|
+
provider: 'resend' | 'ses' | 'smtp';
|
|
127
|
+
};
|
|
128
|
+
onError?: (err: unknown) => Response;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function stringOrEmpty(value: unknown): string
|
|
132
|
+
|
|
133
|
+
function booleanOrFalse(value: unknown): boolean
|
|
134
|
+
|
|
135
|
+
function arrayOrEmpty<T>(value: unknown): T[]
|
|
136
|
+
|
|
137
|
+
function numberOrZero(value: unknown): number
|
|
138
|
+
|
|
139
|
+
function dateOrEmpty(value: unknown): string
|
|
140
|
+
|
|
141
|
+
interface IApiError {
|
|
142
|
+
reason: string;
|
|
143
|
+
explanation: string;
|
|
144
|
+
details?: unknown;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type HttpStatus = (typeof HTTP)[keyof typeof HTTP];
|
|
148
|
+
|
|
149
|
+
const HTTP: { readonly OK: 200; readonly CREATED: 201; readonly ACCEPTED: 202; readonly NO_CONTENT: 204; readonly BAD_REQUEST: 400; readonly UNAUTHORIZED: 401; readonly PAYMENT_REQUIRED: 402; readonly FORBIDDEN: 403; readonly NOT_FOUND: 404; readonly CONFLICT: 409; readonly GONE: 410; readonly UNPROCESSABLE: 422; readonly TOO_MANY_REQUESTS: 429; readonly SERVER_ERROR: 500; readonly NOT_IMPLEMENTED: 501; readonly BAD_GATEWAY: 502; readonly SERVICE_UNAVAILABLE: 503; }
|
|
150
|
+
|
|
151
|
+
function setApiResponse<T>(status: number, reason: string, explanation: string, payload?: T | undefined): Response
|
|
152
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Framework core — request router, middleware pipeline, module system, and shared context types. Every other @fonderie-js package depends on this.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fonderie-js",
|
|
@@ -70,16 +70,17 @@
|
|
|
70
70
|
},
|
|
71
71
|
"files": [
|
|
72
72
|
"dist",
|
|
73
|
+
"brain",
|
|
73
74
|
"LICENSE",
|
|
74
75
|
"README.md"
|
|
75
76
|
],
|
|
76
77
|
"repository": {
|
|
77
78
|
"type": "git",
|
|
78
|
-
"url": "git+https://github.com/
|
|
79
|
+
"url": "git+https://github.com/fonderiejs/sdk.git",
|
|
79
80
|
"directory": "packages/core"
|
|
80
81
|
},
|
|
81
|
-
"homepage": "https://github.com/
|
|
82
|
+
"homepage": "https://github.com/fonderiejs/sdk/tree/main/packages/core#readme",
|
|
82
83
|
"bugs": {
|
|
83
|
-
"url": "https://github.com/
|
|
84
|
+
"url": "https://github.com/fonderiejs/sdk/issues"
|
|
84
85
|
}
|
|
85
86
|
}
|