@donkeylabs/server 0.2.1 → 0.2.8
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/cli/commands/generate.ts +9 -7
- package/examples/starter/.@donkeylabs/server/registry.d.ts +3 -2
- package/examples/starter/package.json +1 -1
- package/examples/starter/src/index.ts +21 -2
- package/examples/starter/src/plugins/stats/index.ts +85 -16
- package/examples/starter/src/routes/health/ping/index.ts +4 -5
- package/examples/starter/src/routes/health/ping/models/model.ts +0 -2
- package/examples/starter/tsconfig.json +7 -1
- package/package.json +1 -1
- package/src/handlers.ts +35 -10
- package/src/index.ts +7 -2
- package/src/router.ts +39 -22
- package/src/server.ts +15 -9
- package/context.d.ts +0 -27
- package/examples/starter/app.db +0 -0
- package/examples/starter/bun.lock +0 -224
- package/examples/starter/src/plugins/stats/migrations/001_initial.ts +0 -17
- package/examples/starter/src/plugins/stats/schema.ts +0 -12
- package/registry.d.ts +0 -11
package/cli/commands/generate.ts
CHANGED
|
@@ -63,6 +63,7 @@ async function extractMiddlewareNames(pluginPath: string): Promise<string[]> {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
|
|
66
67
|
async function findPlugins(
|
|
67
68
|
patterns: string[]
|
|
68
69
|
): Promise<{ name: string; path: string; exportName: string }[]> {
|
|
@@ -181,13 +182,6 @@ async function generateRegistry(
|
|
|
181
182
|
)
|
|
182
183
|
.join("\n");
|
|
183
184
|
|
|
184
|
-
const middlewareBuilderMethods = allMiddleware
|
|
185
|
-
.map(
|
|
186
|
-
({ plugin, middleware }) => ` /** Middleware from ${plugin} */
|
|
187
|
-
${middleware}(config?: InferMiddleware<typeof ${plugin}>["${middleware}"]["__config"]): this;`
|
|
188
|
-
)
|
|
189
|
-
.join("\n");
|
|
190
|
-
|
|
191
185
|
const handlerUnion =
|
|
192
186
|
allHandlers.length > 0
|
|
193
187
|
? `"typed" | "raw" | ${allHandlers.map((h) => `"${h.handler}"`).join(" | ")}`
|
|
@@ -198,6 +192,14 @@ async function generateRegistry(
|
|
|
198
192
|
? allMiddleware.map((m) => `"${m.middleware}"`).join(" | ")
|
|
199
193
|
: "never";
|
|
200
194
|
|
|
195
|
+
// Router middleware methods (returns IRouter for chaining)
|
|
196
|
+
const middlewareBuilderMethods = allMiddleware
|
|
197
|
+
.map(
|
|
198
|
+
({ plugin, middleware }) => ` /** Middleware from ${plugin} */
|
|
199
|
+
${middleware}(config?: InferMiddleware<typeof ${plugin}>["${middleware}"]["__config"]): TRouter;`
|
|
200
|
+
)
|
|
201
|
+
.join("\n");
|
|
202
|
+
|
|
201
203
|
const content = `// Auto-generated by donkeylabs generate
|
|
202
204
|
import { type Register, type InferService, type InferSchema, type InferHandlers, type InferMiddleware, type InferDependencies } from "@donkeylabs/server";
|
|
203
205
|
${importLines}
|
|
@@ -17,7 +17,7 @@ declare module "@donkeylabs/server" {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export type AvailableHandlers = "typed" | "raw";
|
|
20
|
-
export type AvailableMiddleware =
|
|
20
|
+
export type AvailableMiddleware = "timing";
|
|
21
21
|
|
|
22
22
|
declare module "@donkeylabs/server" {
|
|
23
23
|
export interface IRouteBuilder<TRouter> {
|
|
@@ -25,6 +25,7 @@ declare module "@donkeylabs/server" {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface IMiddlewareBuilder<TRouter> {
|
|
28
|
-
|
|
28
|
+
/** Middleware from statsPlugin */
|
|
29
|
+
timing(config?: InferMiddleware<typeof statsPlugin>["timing"]["__config"]): TRouter;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/// <reference path="../.@donkeylabs/server/registry.d.ts" />
|
|
1
2
|
import { db } from "./db";
|
|
2
|
-
import { AppServer } from "@donkeylabs/server";
|
|
3
|
+
import { createRouter, AppServer } from "@donkeylabs/server";
|
|
3
4
|
import { healthRouter } from "./routes/health";
|
|
5
|
+
import { statsPlugin } from "./plugins/stats";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { pingRoute } from "./routes/health/ping";
|
|
4
8
|
|
|
5
9
|
const server = new AppServer({
|
|
6
10
|
port: Number(process.env.PORT) || 3000,
|
|
@@ -8,6 +12,21 @@ const server = new AppServer({
|
|
|
8
12
|
config: { env: process.env.NODE_ENV || "development" },
|
|
9
13
|
});
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
// Register plugins
|
|
16
|
+
server.registerPlugin(statsPlugin);
|
|
17
|
+
|
|
18
|
+
// Register routes with middleware applied at router level
|
|
19
|
+
|
|
20
|
+
const api = server.router("api")
|
|
21
|
+
|
|
22
|
+
api.router("hello").route("test").typed({
|
|
23
|
+
input: z.string(),
|
|
24
|
+
output: z.string(),
|
|
25
|
+
handle: (input, ctx) => {
|
|
26
|
+
return input;
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
api.router(pingRoute)
|
|
12
31
|
|
|
13
32
|
await server.start();
|
|
@@ -1,24 +1,93 @@
|
|
|
1
|
-
import { createPlugin } from "@donkeylabs/server";
|
|
2
|
-
|
|
1
|
+
import { createPlugin, createMiddleware } from "@donkeylabs/server";
|
|
2
|
+
|
|
3
|
+
export interface RequestStats {
|
|
4
|
+
totalRequests: number;
|
|
5
|
+
avgResponseTime: number;
|
|
6
|
+
minResponseTime: number;
|
|
7
|
+
maxResponseTime: number;
|
|
8
|
+
requestsPerRoute: Map<string, number>;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
export interface StatsService {
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
/** Record a request with its duration */
|
|
13
|
+
recordRequest(route: string, durationMs: number): void;
|
|
14
|
+
/** Get current stats snapshot */
|
|
15
|
+
getStats(): RequestStats;
|
|
16
|
+
/** Reset all stats */
|
|
17
|
+
reset(): void;
|
|
7
18
|
}
|
|
8
19
|
|
|
9
|
-
export const statsPlugin = createPlugin
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
export const statsPlugin = createPlugin.define({
|
|
21
|
+
name: "stats",
|
|
22
|
+
version: "1.0.0",
|
|
23
|
+
|
|
24
|
+
middleware: {
|
|
25
|
+
/** Timing middleware - records request duration */
|
|
26
|
+
timing: createMiddleware(async (req, ctx, next) => {
|
|
27
|
+
const route = new URL(req.url).pathname.slice(1);
|
|
28
|
+
const start = performance.now();
|
|
29
|
+
const response = await next();
|
|
30
|
+
const duration = performance.now() - start;
|
|
31
|
+
ctx.plugins.stats.recordRequest(route, duration);
|
|
32
|
+
return response;
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
service: async (ctx): Promise<StatsService> => {
|
|
37
|
+
const logger = ctx.core.logger.child({ plugin: "stats" });
|
|
38
|
+
|
|
39
|
+
// In-memory stats
|
|
40
|
+
let totalRequests = 0;
|
|
41
|
+
let totalTime = 0;
|
|
42
|
+
let minTime = Infinity;
|
|
43
|
+
let maxTime = 0;
|
|
44
|
+
const requestsPerRoute = new Map<string, number>();
|
|
14
45
|
|
|
15
|
-
|
|
16
|
-
|
|
46
|
+
// Register cron to log stats every minute
|
|
47
|
+
ctx.core.cron.schedule("* * * * *", () => {
|
|
48
|
+
const stats = getStats();
|
|
49
|
+
logger.info("Server stats", {
|
|
50
|
+
requests: stats.totalRequests,
|
|
51
|
+
avgMs: stats.avgResponseTime.toFixed(2),
|
|
52
|
+
minMs: stats.minResponseTime === Infinity ? 0 : stats.minResponseTime.toFixed(2),
|
|
53
|
+
maxMs: stats.maxResponseTime.toFixed(2),
|
|
54
|
+
routes: Object.fromEntries(stats.requestsPerRoute),
|
|
55
|
+
});
|
|
56
|
+
}, { name: "stats-reporter" });
|
|
17
57
|
|
|
58
|
+
logger.info("Stats plugin initialized");
|
|
59
|
+
|
|
60
|
+
function getStats(): RequestStats {
|
|
18
61
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
62
|
+
totalRequests,
|
|
63
|
+
avgResponseTime: totalRequests > 0 ? totalTime / totalRequests : 0,
|
|
64
|
+
minResponseTime: minTime,
|
|
65
|
+
maxResponseTime: maxTime,
|
|
66
|
+
requestsPerRoute: new Map(requestsPerRoute),
|
|
22
67
|
};
|
|
23
|
-
}
|
|
24
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
recordRequest(route: string, durationMs: number) {
|
|
72
|
+
totalRequests++;
|
|
73
|
+
totalTime += durationMs;
|
|
74
|
+
minTime = Math.min(minTime, durationMs);
|
|
75
|
+
maxTime = Math.max(maxTime, durationMs);
|
|
76
|
+
requestsPerRoute.set(route, (requestsPerRoute.get(route) ?? 0) + 1);
|
|
77
|
+
|
|
78
|
+
logger.debug("Request recorded", { route, durationMs: durationMs.toFixed(2) });
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
getStats,
|
|
82
|
+
|
|
83
|
+
reset() {
|
|
84
|
+
totalRequests = 0;
|
|
85
|
+
totalTime = 0;
|
|
86
|
+
minTime = Infinity;
|
|
87
|
+
maxTime = 0;
|
|
88
|
+
requestsPerRoute.clear();
|
|
89
|
+
logger.info("Stats reset");
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
// Route definition
|
|
2
|
-
|
|
3
|
-
import type { AppRoute } from "@donkeylabs/server";
|
|
1
|
+
// Route definition with full type inference
|
|
2
|
+
import { createRoute } from "@donkeylabs/server";
|
|
4
3
|
import { Input, Output } from "./schema";
|
|
5
4
|
import { PingModel } from "./models/model";
|
|
6
5
|
|
|
7
|
-
export const pingRoute
|
|
6
|
+
export const pingRoute = createRoute.typed({
|
|
8
7
|
input: Input,
|
|
9
8
|
output: Output,
|
|
10
9
|
handle: async (input, ctx) => {
|
|
11
10
|
const model = new PingModel(ctx);
|
|
12
11
|
return model.handle(input);
|
|
13
12
|
},
|
|
14
|
-
};
|
|
13
|
+
});
|
|
@@ -7,7 +7,6 @@ import { AppContext } from "$server/context";
|
|
|
7
7
|
* Model class with handler logic.
|
|
8
8
|
*/
|
|
9
9
|
export class PingModel implements Handler<Health.Ping> {
|
|
10
|
-
|
|
11
10
|
ctx: AppContext;
|
|
12
11
|
|
|
13
12
|
constructor(ctx: AppContext) {
|
|
@@ -19,7 +18,6 @@ export class PingModel implements Handler<Health.Ping> {
|
|
|
19
18
|
status: "ok",
|
|
20
19
|
timestamp: new Date().toISOString(),
|
|
21
20
|
echo: input.echo,
|
|
22
|
-
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
}
|
package/package.json
CHANGED
package/src/handlers.ts
CHANGED
|
@@ -51,22 +51,47 @@ export interface Route<T extends RouteContract> {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
* Use when you don't need generated route types.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* export const healthRoute: AppRoute = {
|
|
59
|
-
* input: z.object({ echo: z.string().optional() }),
|
|
60
|
-
* output: z.object({ status: z.string() }),
|
|
61
|
-
* handle: async (input, ctx) => ({ status: "ok" }),
|
|
62
|
-
* };
|
|
54
|
+
* Route configuration with inferred types from zod schemas.
|
|
63
55
|
*/
|
|
64
|
-
export interface
|
|
56
|
+
export interface TypedRouteConfig<TInput, TOutput> {
|
|
65
57
|
input: z.ZodType<TInput>;
|
|
66
58
|
output: z.ZodType<TOutput>;
|
|
67
59
|
handle: (input: TInput, ctx: ServerContext) => TOutput | Promise<TOutput>;
|
|
68
60
|
}
|
|
69
61
|
|
|
62
|
+
export interface RawRouteConfig {
|
|
63
|
+
handle: (req: Request, ctx: ServerContext) => Response | Promise<Response>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a typed route with full type inference from zod schemas.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* export const pingRoute = createRoute.typed({
|
|
71
|
+
* input: z.object({ echo: z.string().optional() }),
|
|
72
|
+
* output: z.object({ status: z.literal("ok"), timestamp: z.string() }),
|
|
73
|
+
* handle: async (input, ctx) => ({
|
|
74
|
+
* status: "ok",
|
|
75
|
+
* timestamp: new Date().toISOString(),
|
|
76
|
+
* }),
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
export const createRoute = {
|
|
80
|
+
typed<TInput, TOutput>(config: TypedRouteConfig<TInput, TOutput>) {
|
|
81
|
+
return {
|
|
82
|
+
...config,
|
|
83
|
+
_handler: "typed" as const,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
raw(config: RawRouteConfig) {
|
|
88
|
+
return {
|
|
89
|
+
...config,
|
|
90
|
+
_handler: "raw" as const,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
70
95
|
// ============================================
|
|
71
96
|
// Handler Runtimes
|
|
72
97
|
// ============================================
|
package/src/index.ts
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
export { AppServer, type ServerConfig } from "./server";
|
|
5
5
|
|
|
6
6
|
// Router
|
|
7
|
-
export { createRouter, type Router, type RouteBuilder, type ServerContext } from "./router";
|
|
7
|
+
export { createRouter, type Router, type RouteBuilder, type ServerContext, type IRouter, type IRouteBuilder, type IMiddlewareBuilder } from "./router";
|
|
8
8
|
|
|
9
9
|
// Handlers and Route types
|
|
10
10
|
export {
|
|
11
11
|
createHandler,
|
|
12
|
+
createRoute,
|
|
12
13
|
TypedHandler,
|
|
13
14
|
RawHandler,
|
|
14
15
|
type Handler,
|
|
15
16
|
type Route,
|
|
16
|
-
type AppRoute,
|
|
17
17
|
type RouteContract,
|
|
18
18
|
} from "./handlers";
|
|
19
19
|
|
|
@@ -27,6 +27,11 @@ export {
|
|
|
27
27
|
type PluginMiddlewareRegistry,
|
|
28
28
|
type CoreServices,
|
|
29
29
|
type Register,
|
|
30
|
+
type InferService,
|
|
31
|
+
type InferSchema,
|
|
32
|
+
type InferHandlers,
|
|
33
|
+
type InferMiddleware,
|
|
34
|
+
type InferDependencies,
|
|
30
35
|
} from "./core";
|
|
31
36
|
|
|
32
37
|
// Middleware
|
package/src/router.ts
CHANGED
|
@@ -6,6 +6,9 @@ import type { MiddlewareDefinition } from "./middleware";
|
|
|
6
6
|
|
|
7
7
|
export type ServerContext = GlobalContext;
|
|
8
8
|
|
|
9
|
+
/** Base interface for middleware builder - extended by generated types */
|
|
10
|
+
export interface IMiddlewareBuilder<TRouter> {}
|
|
11
|
+
|
|
9
12
|
export interface HandlerRegistry extends PluginHandlerRegistry {
|
|
10
13
|
typed: {
|
|
11
14
|
execute(req: Request, def: any, userHandle: Function, ctx: ServerContext): Promise<Response>;
|
|
@@ -58,26 +61,6 @@ export interface IRouteBuilderBase<TRouter> {
|
|
|
58
61
|
|
|
59
62
|
export interface IRouteBuilder<TRouter> extends IRouteBuilderBase<TRouter> {}
|
|
60
63
|
|
|
61
|
-
export interface IMiddlewareBuilderBase<TRouter> {
|
|
62
|
-
route(name: string): IRouteBuilder<TRouter>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface IMiddlewareBuilder<TRouter> extends IMiddlewareBuilderBase<TRouter> {}
|
|
66
|
-
|
|
67
|
-
export class MiddlewareBuilder<TRouter extends Router> implements IMiddlewareBuilderBase<TRouter> {
|
|
68
|
-
private _middleware: MiddlewareDefinition[] = [];
|
|
69
|
-
|
|
70
|
-
constructor(private router: TRouter) {}
|
|
71
|
-
|
|
72
|
-
route(name: string): IRouteBuilder<TRouter> {
|
|
73
|
-
return new RouteBuilder(this.router, name, this._middleware) as unknown as IRouteBuilder<TRouter>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
addMiddleware(name: string, config: any): this {
|
|
77
|
-
this._middleware.push({ name, config });
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
64
|
|
|
82
65
|
export class RouteBuilder<TRouter extends Router> implements IRouteBuilderBase<TRouter> {
|
|
83
66
|
constructor(
|
|
@@ -101,6 +84,7 @@ export class RouteBuilder<TRouter extends Router> implements IRouteBuilderBase<T
|
|
|
101
84
|
|
|
102
85
|
export interface IRouter {
|
|
103
86
|
route(name: string): IRouteBuilder<this>;
|
|
87
|
+
router(prefixOrRouter: string | IRouter): IRouter;
|
|
104
88
|
middleware: IMiddlewareBuilder<this>;
|
|
105
89
|
getRoutes(): RouteDefinition<any, any, any>[];
|
|
106
90
|
getMetadata(): RouteMetadata[];
|
|
@@ -110,17 +94,35 @@ export interface IRouter {
|
|
|
110
94
|
export class Router implements IRouter {
|
|
111
95
|
private routes: Map<string, RouteDefinition<any, any, any>> = new Map();
|
|
112
96
|
private prefix: string;
|
|
97
|
+
private _middlewareStack: MiddlewareDefinition[] = [];
|
|
113
98
|
|
|
114
99
|
constructor(prefix: string = "") {
|
|
115
100
|
this.prefix = prefix;
|
|
116
101
|
}
|
|
117
102
|
|
|
118
103
|
route(name: string): IRouteBuilder<this> {
|
|
119
|
-
return new RouteBuilder(this, name) as unknown as IRouteBuilder<this>;
|
|
104
|
+
return new RouteBuilder(this, name, this._middlewareStack) as unknown as IRouteBuilder<this>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Create a nested router or register a child router */
|
|
108
|
+
router(prefixOrRouter: string | IRouter): IRouter {
|
|
109
|
+
if (typeof prefixOrRouter === "string") {
|
|
110
|
+
const fullPrefix = this.prefix ? `${this.prefix}.${prefixOrRouter}` : prefixOrRouter;
|
|
111
|
+
const childRouter = new Router(fullPrefix);
|
|
112
|
+
childRouter._middlewareStack = [...this._middlewareStack];
|
|
113
|
+
return childRouter;
|
|
114
|
+
}
|
|
115
|
+
// Merge child router's routes into this router
|
|
116
|
+
for (const route of prefixOrRouter.getRoutes()) {
|
|
117
|
+
const fullName = this.prefix ? `${this.prefix}.${route.name}` : route.name;
|
|
118
|
+
this.routes.set(fullName, { ...route, name: fullName, middleware: [...this._middlewareStack, ...(route.middleware || [])] });
|
|
119
|
+
}
|
|
120
|
+
return this;
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
/** Middleware builder - chain middleware before defining routes */
|
|
122
124
|
get middleware(): IMiddlewareBuilder<this> {
|
|
123
|
-
return
|
|
125
|
+
return createMiddlewareBuilderProxy(this);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
addRoute(name: string, handler: string, config: any, middleware: MiddlewareDefinition[] = []): this {
|
|
@@ -152,4 +154,19 @@ export class Router implements IRouter {
|
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
/** Creates a Proxy that intercepts middleware method calls and adds them to the router's middleware stack */
|
|
158
|
+
function createMiddlewareBuilderProxy<TRouter extends Router>(router: TRouter): IMiddlewareBuilder<TRouter> {
|
|
159
|
+
return new Proxy({} as IMiddlewareBuilder<TRouter>, {
|
|
160
|
+
get(_target, prop) {
|
|
161
|
+
if (typeof prop === "string") {
|
|
162
|
+
return (config?: any) => {
|
|
163
|
+
router["_middlewareStack"].push({ name: prop, config });
|
|
164
|
+
return router;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return undefined;
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
155
172
|
export const createRouter = (prefix?: string): IRouter => new Router(prefix);
|
package/src/server.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PluginManager, type CoreServices, type ConfiguredPlugin } from "./core";
|
|
3
|
-
import { type IRouter, type RouteDefinition, type ServerContext } from "./router";
|
|
3
|
+
import { Router as RouterImpl, type IRouter, type RouteDefinition, type ServerContext } from "./router";
|
|
4
4
|
import { Handlers } from "./handlers";
|
|
5
5
|
import type { MiddlewareRuntime, MiddlewareDefinition } from "./middleware";
|
|
6
6
|
import {
|
|
@@ -78,9 +78,15 @@ export class AppServer {
|
|
|
78
78
|
return this;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
/** Create a new router with prefix or register an existing router */
|
|
82
|
+
router(prefixOrRouter: string | IRouter): IRouter {
|
|
83
|
+
if (typeof prefixOrRouter === "string") {
|
|
84
|
+
const newRouter = new RouterImpl(prefixOrRouter);
|
|
85
|
+
this.routers.push(newRouter);
|
|
86
|
+
return newRouter;
|
|
87
|
+
}
|
|
88
|
+
this.routers.push(prefixOrRouter);
|
|
89
|
+
return prefixOrRouter;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
getServices(): any {
|
|
@@ -195,14 +201,14 @@ export class AppServer {
|
|
|
195
201
|
requestId: crypto.randomUUID(),
|
|
196
202
|
};
|
|
197
203
|
|
|
198
|
-
const
|
|
199
|
-
const
|
|
204
|
+
const routeMiddleware = route.middleware || [];
|
|
205
|
+
const routeHandler = async () => handler.execute(req, route, route.handle, ctx);
|
|
200
206
|
|
|
201
207
|
try {
|
|
202
|
-
if (
|
|
203
|
-
return await this.executeMiddlewareChain(req, ctx,
|
|
208
|
+
if (routeMiddleware.length > 0) {
|
|
209
|
+
return await this.executeMiddlewareChain(req, ctx, routeMiddleware, routeHandler);
|
|
204
210
|
}
|
|
205
|
-
return await
|
|
211
|
+
return await routeHandler();
|
|
206
212
|
} catch (error) {
|
|
207
213
|
if (error instanceof HttpError) {
|
|
208
214
|
logger.warn("HTTP error thrown", {
|
package/context.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Auto-generated by scripts/generate-server.ts
|
|
3
|
-
// Do not edit manually.
|
|
4
|
-
|
|
5
|
-
/// <reference path="./registry.d.ts" />
|
|
6
|
-
import type { PluginRegistry, CoreServices } from "./src/core";
|
|
7
|
-
import type { Errors } from "./src/core/errors";
|
|
8
|
-
import type { Kysely } from "kysely";
|
|
9
|
-
|
|
10
|
-
// Intersection of all plugin schemas - enables db.selectFrom("users"), db.selectFrom("posts"), etc.
|
|
11
|
-
type DatabaseSchema = {};
|
|
12
|
-
|
|
13
|
-
export interface GlobalContext {
|
|
14
|
-
db: Kysely<DatabaseSchema>;
|
|
15
|
-
plugins: {
|
|
16
|
-
[K in keyof PluginRegistry]: PluginRegistry[K]["service"];
|
|
17
|
-
};
|
|
18
|
-
core: CoreServices;
|
|
19
|
-
/** Convenience access to error factories - same as core.errors */
|
|
20
|
-
errors: Errors;
|
|
21
|
-
/** Application config */
|
|
22
|
-
config: Record<string, any>;
|
|
23
|
-
ip: string;
|
|
24
|
-
/** Unique request ID */
|
|
25
|
-
requestId: string;
|
|
26
|
-
user?: any;
|
|
27
|
-
}
|
package/examples/starter/app.db
DELETED
|
File without changes
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 1,
|
|
3
|
-
"workspaces": {
|
|
4
|
-
"": {
|
|
5
|
-
"name": "starter",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@donkeylabs/server": "0.2.0",
|
|
8
|
-
"kysely": "^0.27.0",
|
|
9
|
-
"kysely-bun-sqlite": "^0.3.0",
|
|
10
|
-
"zod": "^3.24.0",
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@types/bun": "latest",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
"packages": {
|
|
18
|
-
"@donkeylabs/server": ["@donkeylabs/server@0.2.0", "", { "dependencies": { "@modelcontextprotocol/sdk": "^1.25.2", "picocolors": "^1.1.1", "prompts": "^2.4.2" }, "peerDependencies": { "kysely": "^0.27.0 || ^0.28.0", "typescript": "^5", "zod": "^3.20.0" }, "bin": { "donkeylabs": "cli/index.ts", "donkeylabs-mcp": "mcp/server.ts" } }, "sha512-MMKo1MHsNyAQ8VBJsTsGn+wzJpPpdfo6NMd1E++4360chs+i7nFu9i0Fm/PQYoXyqmpoXT6+avIM1zaWTBF2KA=="],
|
|
19
|
-
|
|
20
|
-
"@hono/node-server": ["@hono/node-server@1.19.8", "", { "peerDependencies": { "hono": "^4" } }, "sha512-0/g2lIOPzX8f3vzW1ggQgvG5mjtFBDBHFAzI5SFAi2DzSqS9luJwqg9T6O/gKYLi+inS7eNxBeIFkkghIPvrMA=="],
|
|
21
|
-
|
|
22
|
-
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.25.2", "", { "dependencies": { "@hono/node-server": "^1.19.7", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "jose": "^6.1.1", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.0" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-LZFeo4F9M5qOhC/Uc1aQSrBHxMrvxett+9KLHt7OhcExtoiRN9DKgbZffMP/nxjutWDQpfMDfP3nkHI4X9ijww=="],
|
|
23
|
-
|
|
24
|
-
"@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="],
|
|
25
|
-
|
|
26
|
-
"@types/node": ["@types/node@25.0.8", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg=="],
|
|
27
|
-
|
|
28
|
-
"accepts": ["accepts@2.0.0", "", { "dependencies": { "mime-types": "^3.0.0", "negotiator": "^1.0.0" } }, "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng=="],
|
|
29
|
-
|
|
30
|
-
"ajv": ["ajv@8.17.1", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2" } }, "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g=="],
|
|
31
|
-
|
|
32
|
-
"ajv-formats": ["ajv-formats@3.0.1", "", { "dependencies": { "ajv": "^8.0.0" } }, "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ=="],
|
|
33
|
-
|
|
34
|
-
"body-parser": ["body-parser@2.2.2", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.1", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA=="],
|
|
35
|
-
|
|
36
|
-
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
|
|
37
|
-
|
|
38
|
-
"bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="],
|
|
39
|
-
|
|
40
|
-
"call-bind-apply-helpers": ["call-bind-apply-helpers@1.0.2", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
|
41
|
-
|
|
42
|
-
"call-bound": ["call-bound@1.0.4", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "get-intrinsic": "^1.3.0" } }, "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg=="],
|
|
43
|
-
|
|
44
|
-
"content-disposition": ["content-disposition@1.0.1", "", {}, "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q=="],
|
|
45
|
-
|
|
46
|
-
"content-type": ["content-type@1.0.5", "", {}, "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA=="],
|
|
47
|
-
|
|
48
|
-
"cookie": ["cookie@0.7.2", "", {}, "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w=="],
|
|
49
|
-
|
|
50
|
-
"cookie-signature": ["cookie-signature@1.2.2", "", {}, "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg=="],
|
|
51
|
-
|
|
52
|
-
"cors": ["cors@2.8.5", "", { "dependencies": { "object-assign": "^4", "vary": "^1" } }, "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g=="],
|
|
53
|
-
|
|
54
|
-
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
|
55
|
-
|
|
56
|
-
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
|
57
|
-
|
|
58
|
-
"depd": ["depd@2.0.0", "", {}, "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw=="],
|
|
59
|
-
|
|
60
|
-
"dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="],
|
|
61
|
-
|
|
62
|
-
"ee-first": ["ee-first@1.1.1", "", {}, "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="],
|
|
63
|
-
|
|
64
|
-
"encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="],
|
|
65
|
-
|
|
66
|
-
"es-define-property": ["es-define-property@1.0.1", "", {}, "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g=="],
|
|
67
|
-
|
|
68
|
-
"es-errors": ["es-errors@1.3.0", "", {}, "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="],
|
|
69
|
-
|
|
70
|
-
"es-object-atoms": ["es-object-atoms@1.1.1", "", { "dependencies": { "es-errors": "^1.3.0" } }, "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA=="],
|
|
71
|
-
|
|
72
|
-
"escape-html": ["escape-html@1.0.3", "", {}, "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="],
|
|
73
|
-
|
|
74
|
-
"etag": ["etag@1.8.1", "", {}, "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="],
|
|
75
|
-
|
|
76
|
-
"eventsource": ["eventsource@3.0.7", "", { "dependencies": { "eventsource-parser": "^3.0.1" } }, "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA=="],
|
|
77
|
-
|
|
78
|
-
"eventsource-parser": ["eventsource-parser@3.0.6", "", {}, "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg=="],
|
|
79
|
-
|
|
80
|
-
"express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
|
|
81
|
-
|
|
82
|
-
"express-rate-limit": ["express-rate-limit@7.5.1", "", { "peerDependencies": { "express": ">= 4.11" } }, "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw=="],
|
|
83
|
-
|
|
84
|
-
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
|
85
|
-
|
|
86
|
-
"fast-uri": ["fast-uri@3.1.0", "", {}, "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA=="],
|
|
87
|
-
|
|
88
|
-
"finalhandler": ["finalhandler@2.1.1", "", { "dependencies": { "debug": "^4.4.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "on-finished": "^2.4.1", "parseurl": "^1.3.3", "statuses": "^2.0.1" } }, "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA=="],
|
|
89
|
-
|
|
90
|
-
"forwarded": ["forwarded@0.2.0", "", {}, "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="],
|
|
91
|
-
|
|
92
|
-
"fresh": ["fresh@2.0.0", "", {}, "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A=="],
|
|
93
|
-
|
|
94
|
-
"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],
|
|
95
|
-
|
|
96
|
-
"get-intrinsic": ["get-intrinsic@1.3.0", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.2", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", "get-proto": "^1.0.1", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", "math-intrinsics": "^1.1.0" } }, "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ=="],
|
|
97
|
-
|
|
98
|
-
"get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="],
|
|
99
|
-
|
|
100
|
-
"gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="],
|
|
101
|
-
|
|
102
|
-
"has-symbols": ["has-symbols@1.1.0", "", {}, "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="],
|
|
103
|
-
|
|
104
|
-
"hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="],
|
|
105
|
-
|
|
106
|
-
"hono": ["hono@4.11.4", "", {}, "sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA=="],
|
|
107
|
-
|
|
108
|
-
"http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
|
|
109
|
-
|
|
110
|
-
"iconv-lite": ["iconv-lite@0.7.2", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw=="],
|
|
111
|
-
|
|
112
|
-
"inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
|
|
113
|
-
|
|
114
|
-
"ipaddr.js": ["ipaddr.js@1.9.1", "", {}, "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="],
|
|
115
|
-
|
|
116
|
-
"is-promise": ["is-promise@4.0.0", "", {}, "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ=="],
|
|
117
|
-
|
|
118
|
-
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
|
|
119
|
-
|
|
120
|
-
"jose": ["jose@6.1.3", "", {}, "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ=="],
|
|
121
|
-
|
|
122
|
-
"json-schema-traverse": ["json-schema-traverse@1.0.0", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
|
|
123
|
-
|
|
124
|
-
"json-schema-typed": ["json-schema-typed@8.0.2", "", {}, "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA=="],
|
|
125
|
-
|
|
126
|
-
"kleur": ["kleur@3.0.3", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="],
|
|
127
|
-
|
|
128
|
-
"kysely": ["kysely@0.27.6", "", {}, "sha512-FIyV/64EkKhJmjgC0g2hygpBv5RNWVPyNCqSAD7eTCv6eFWNIi4PN1UvdSJGicN/o35bnevgis4Y0UDC0qi8jQ=="],
|
|
129
|
-
|
|
130
|
-
"kysely-bun-sqlite": ["kysely-bun-sqlite@0.3.2", "", { "dependencies": { "bun-types": "^1.0.25" }, "peerDependencies": { "kysely": "^0.27.2" } }, "sha512-YucMcOGGxNCmlAnkvNfTKZX6Bk1sYsuVVXlQN/5ZUgerlq/J9/EuR3aMOOZ25ASLM7oMglSxfeQxkiw0+hrEOQ=="],
|
|
131
|
-
|
|
132
|
-
"math-intrinsics": ["math-intrinsics@1.1.0", "", {}, "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="],
|
|
133
|
-
|
|
134
|
-
"media-typer": ["media-typer@1.1.0", "", {}, "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw=="],
|
|
135
|
-
|
|
136
|
-
"merge-descriptors": ["merge-descriptors@2.0.0", "", {}, "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g=="],
|
|
137
|
-
|
|
138
|
-
"mime-db": ["mime-db@1.54.0", "", {}, "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ=="],
|
|
139
|
-
|
|
140
|
-
"mime-types": ["mime-types@3.0.2", "", { "dependencies": { "mime-db": "^1.54.0" } }, "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A=="],
|
|
141
|
-
|
|
142
|
-
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
143
|
-
|
|
144
|
-
"negotiator": ["negotiator@1.0.0", "", {}, "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="],
|
|
145
|
-
|
|
146
|
-
"object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],
|
|
147
|
-
|
|
148
|
-
"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
|
149
|
-
|
|
150
|
-
"on-finished": ["on-finished@2.4.1", "", { "dependencies": { "ee-first": "1.1.1" } }, "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg=="],
|
|
151
|
-
|
|
152
|
-
"once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
|
153
|
-
|
|
154
|
-
"parseurl": ["parseurl@1.3.3", "", {}, "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="],
|
|
155
|
-
|
|
156
|
-
"path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="],
|
|
157
|
-
|
|
158
|
-
"path-to-regexp": ["path-to-regexp@8.3.0", "", {}, "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA=="],
|
|
159
|
-
|
|
160
|
-
"picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
|
161
|
-
|
|
162
|
-
"pkce-challenge": ["pkce-challenge@5.0.1", "", {}, "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ=="],
|
|
163
|
-
|
|
164
|
-
"prompts": ["prompts@2.4.2", "", { "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" } }, "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q=="],
|
|
165
|
-
|
|
166
|
-
"proxy-addr": ["proxy-addr@2.0.7", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg=="],
|
|
167
|
-
|
|
168
|
-
"qs": ["qs@6.14.1", "", { "dependencies": { "side-channel": "^1.1.0" } }, "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ=="],
|
|
169
|
-
|
|
170
|
-
"range-parser": ["range-parser@1.2.1", "", {}, "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="],
|
|
171
|
-
|
|
172
|
-
"raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
|
173
|
-
|
|
174
|
-
"require-from-string": ["require-from-string@2.0.2", "", {}, "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="],
|
|
175
|
-
|
|
176
|
-
"router": ["router@2.2.0", "", { "dependencies": { "debug": "^4.4.0", "depd": "^2.0.0", "is-promise": "^4.0.0", "parseurl": "^1.3.3", "path-to-regexp": "^8.0.0" } }, "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ=="],
|
|
177
|
-
|
|
178
|
-
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
179
|
-
|
|
180
|
-
"send": ["send@1.2.1", "", { "dependencies": { "debug": "^4.4.3", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.1", "mime-types": "^3.0.2", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.2" } }, "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ=="],
|
|
181
|
-
|
|
182
|
-
"serve-static": ["serve-static@2.2.1", "", { "dependencies": { "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "parseurl": "^1.3.3", "send": "^1.2.0" } }, "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw=="],
|
|
183
|
-
|
|
184
|
-
"setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="],
|
|
185
|
-
|
|
186
|
-
"shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],
|
|
187
|
-
|
|
188
|
-
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
|
189
|
-
|
|
190
|
-
"side-channel": ["side-channel@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3", "side-channel-list": "^1.0.0", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" } }, "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw=="],
|
|
191
|
-
|
|
192
|
-
"side-channel-list": ["side-channel-list@1.0.0", "", { "dependencies": { "es-errors": "^1.3.0", "object-inspect": "^1.13.3" } }, "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA=="],
|
|
193
|
-
|
|
194
|
-
"side-channel-map": ["side-channel-map@1.0.1", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3" } }, "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA=="],
|
|
195
|
-
|
|
196
|
-
"side-channel-weakmap": ["side-channel-weakmap@1.0.2", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "get-intrinsic": "^1.2.5", "object-inspect": "^1.13.3", "side-channel-map": "^1.0.1" } }, "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A=="],
|
|
197
|
-
|
|
198
|
-
"sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="],
|
|
199
|
-
|
|
200
|
-
"statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="],
|
|
201
|
-
|
|
202
|
-
"toidentifier": ["toidentifier@1.0.1", "", {}, "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="],
|
|
203
|
-
|
|
204
|
-
"type-is": ["type-is@2.0.1", "", { "dependencies": { "content-type": "^1.0.5", "media-typer": "^1.1.0", "mime-types": "^3.0.0" } }, "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw=="],
|
|
205
|
-
|
|
206
|
-
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
207
|
-
|
|
208
|
-
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
209
|
-
|
|
210
|
-
"unpipe": ["unpipe@1.0.0", "", {}, "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="],
|
|
211
|
-
|
|
212
|
-
"vary": ["vary@1.1.2", "", {}, "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="],
|
|
213
|
-
|
|
214
|
-
"which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="],
|
|
215
|
-
|
|
216
|
-
"wrappy": ["wrappy@1.0.2", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
|
|
217
|
-
|
|
218
|
-
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
|
219
|
-
|
|
220
|
-
"zod-to-json-schema": ["zod-to-json-schema@3.25.1", "", { "peerDependencies": { "zod": "^3.25 || ^4" } }, "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA=="],
|
|
221
|
-
|
|
222
|
-
"kysely-bun-sqlite/bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
|
|
223
|
-
}
|
|
224
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Kysely } from "kysely";
|
|
2
|
-
|
|
3
|
-
export async function up(db: Kysely<any>) {
|
|
4
|
-
// Create your tables here
|
|
5
|
-
// await db.schema
|
|
6
|
-
// .createTable("stats")
|
|
7
|
-
// .ifNotExists()
|
|
8
|
-
// .addColumn("id", "integer", (col) => col.primaryKey().autoIncrement())
|
|
9
|
-
// .addColumn("name", "text", (col) => col.notNull())
|
|
10
|
-
// .addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`))
|
|
11
|
-
// .execute();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function down(db: Kysely<any>) {
|
|
15
|
-
// Drop your tables here
|
|
16
|
-
// await db.schema.dropTable("stats").ifExists().execute();
|
|
17
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Database schema types for stats plugin
|
|
2
|
-
// Run `bun run gen:types` to regenerate from database
|
|
3
|
-
|
|
4
|
-
export interface DB {
|
|
5
|
-
// Define your table interfaces here
|
|
6
|
-
// Example:
|
|
7
|
-
// stats: {
|
|
8
|
-
// id: Generated<number>;
|
|
9
|
-
// name: string;
|
|
10
|
-
// created_at: Generated<string>;
|
|
11
|
-
// };
|
|
12
|
-
}
|
package/registry.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin and handler registry.
|
|
3
|
-
* This is a stub - run `donkeylabs generate` to create project-specific types.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Extend PluginHandlerRegistry in your project's generated types
|
|
7
|
-
declare module "./src/core" {
|
|
8
|
-
interface PluginHandlerRegistry {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {};
|