@donkeylabs/server 0.3.0 → 0.3.1
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/docs/api-client.md +7 -7
- package/docs/cache.md +1 -74
- package/docs/core-services.md +4 -116
- package/docs/cron.md +1 -1
- package/docs/errors.md +2 -2
- package/docs/events.md +3 -98
- package/docs/handlers.md +13 -48
- package/docs/logger.md +3 -58
- package/docs/middleware.md +2 -2
- package/docs/plugins.md +13 -64
- package/docs/project-structure.md +4 -142
- package/docs/rate-limiter.md +4 -136
- package/docs/router.md +6 -14
- package/docs/sse.md +1 -99
- package/docs/sveltekit-adapter.md +420 -0
- package/package.json +6 -6
- package/registry.d.ts +15 -14
- package/src/core/cache.ts +0 -75
- package/src/core/cron.ts +3 -96
- package/src/core/errors.ts +78 -11
- package/src/core/events.ts +1 -47
- package/src/core/index.ts +0 -4
- package/src/core/jobs.ts +0 -112
- package/src/core/logger.ts +12 -79
- package/src/core/rate-limiter.ts +29 -108
- package/src/core/sse.ts +1 -84
- package/src/core.ts +13 -104
- package/src/generator/index.ts +551 -0
- package/src/handlers.ts +14 -110
- package/src/index.ts +19 -23
- package/src/middleware.ts +2 -5
- package/src/registry.ts +4 -0
- package/src/server.ts +354 -337
- package/README.md +0 -254
- package/cli/commands/dev.ts +0 -134
- package/cli/commands/generate.ts +0 -605
- package/cli/commands/init.ts +0 -205
- package/cli/commands/interactive.ts +0 -417
- package/cli/commands/plugin.ts +0 -192
- package/cli/commands/route.ts +0 -195
- package/cli/donkeylabs +0 -2
- package/cli/index.ts +0 -114
- package/docs/svelte-frontend.md +0 -324
- package/docs/testing.md +0 -438
- package/mcp/donkeylabs-mcp +0 -3238
- package/mcp/server.ts +0 -3238
package/src/index.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// @donkeylabs/server - Main exports
|
|
2
2
|
|
|
3
3
|
// Server
|
|
4
|
-
export { AppServer, type ServerConfig
|
|
4
|
+
export { AppServer, type ServerConfig } from "./server";
|
|
5
5
|
|
|
6
6
|
// Router
|
|
7
7
|
export { createRouter, type Router, type RouteBuilder, type ServerContext, type IRouter, type IRouteBuilder, type IMiddlewareBuilder } from "./router";
|
|
8
8
|
|
|
9
|
-
// Handlers
|
|
9
|
+
// Handlers
|
|
10
10
|
export {
|
|
11
11
|
createHandler,
|
|
12
|
-
createRoute,
|
|
13
12
|
TypedHandler,
|
|
14
13
|
RawHandler,
|
|
15
|
-
|
|
14
|
+
Handlers,
|
|
16
15
|
type HandlerRuntime,
|
|
17
|
-
type
|
|
18
|
-
type
|
|
16
|
+
type TypedFn,
|
|
17
|
+
type TypedHandler as TypedHandlerType,
|
|
18
|
+
type RawFn,
|
|
19
|
+
type RawHandler as RawHandlerType,
|
|
19
20
|
} from "./handlers";
|
|
20
21
|
|
|
21
22
|
// Core Plugin System
|
|
@@ -40,29 +41,24 @@ export {
|
|
|
40
41
|
export { createMiddleware } from "./middleware";
|
|
41
42
|
|
|
42
43
|
// Config helper
|
|
43
|
-
export
|
|
44
|
+
export interface DonkeylabsConfig {
|
|
45
|
+
/** Glob patterns for plugin files */
|
|
44
46
|
plugins: string[];
|
|
47
|
+
/** Output directory for generated types */
|
|
45
48
|
outDir: string;
|
|
49
|
+
/** Server entry file for route extraction */
|
|
50
|
+
entry?: string;
|
|
51
|
+
/** Route files pattern */
|
|
46
52
|
routes?: string;
|
|
53
|
+
/** Client generation options */
|
|
47
54
|
client?: { output: string };
|
|
48
|
-
|
|
55
|
+
/** Adapter package for framework-specific generation (e.g., "@donkeylabs/adapter-sveltekit") */
|
|
56
|
+
adapter?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function defineConfig(config: DonkeylabsConfig): DonkeylabsConfig {
|
|
49
60
|
return config;
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
// Re-export HttpError for custom error creation
|
|
53
64
|
export { HttpError } from "./core/errors";
|
|
54
|
-
|
|
55
|
-
// Re-export SSE types for channel configuration
|
|
56
|
-
export { type SSEChannelConfig } from "./core/sse";
|
|
57
|
-
|
|
58
|
-
// Re-export Rate Limiter types for rule configuration
|
|
59
|
-
export { type RateLimitRule, type RateLimitResult } from "./core/rate-limiter";
|
|
60
|
-
|
|
61
|
-
// Re-export Job types for job registration
|
|
62
|
-
export { type JobDefinition, type RegisteredJob } from "./core/jobs";
|
|
63
|
-
|
|
64
|
-
// Re-export Cron types for cron task registration
|
|
65
|
-
export { type CronTaskDefinition, type CronTask } from "./core/cron";
|
|
66
|
-
|
|
67
|
-
// Re-export Cache types for namespacing
|
|
68
|
-
export { type NamespacedCache } from "./core/cache";
|
package/src/middleware.ts
CHANGED
|
@@ -3,8 +3,7 @@ import type { ServerContext } from "./router";
|
|
|
3
3
|
// The next function - calls the next middleware or handler
|
|
4
4
|
export type NextFn = () => Promise<Response>;
|
|
5
5
|
|
|
6
|
-
// Middleware function signature
|
|
7
|
-
// ctx is ServerContext (request-time context with db, plugins, etc.)
|
|
6
|
+
// Middleware function signature (what plugins implement)
|
|
8
7
|
export type MiddlewareFn<TConfig = void> = (
|
|
9
8
|
req: Request,
|
|
10
9
|
ctx: ServerContext,
|
|
@@ -18,9 +17,7 @@ export interface MiddlewareRuntime<TConfig = void> {
|
|
|
18
17
|
readonly __config: TConfig; // Phantom type for config inference
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
// Factory to create middleware
|
|
22
|
-
// Note: For typed plugin access, use the middleware function pattern in createPlugin.define()
|
|
23
|
-
// which gives you PluginContext in the closure
|
|
20
|
+
// Factory to create middleware (mirrors createHandler pattern)
|
|
24
21
|
export function createMiddleware<TConfig = void>(
|
|
25
22
|
execute: MiddlewareFn<TConfig>
|
|
26
23
|
): MiddlewareRuntime<TConfig> {
|
package/src/registry.ts
ADDED