weifuwu 0.30.0 → 0.30.2
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/README.md +115 -203
- package/dist/core/router.d.ts +21 -58
- package/dist/core/serve.d.ts +0 -4
- package/dist/core/ws.d.ts +28 -0
- package/dist/index.d.ts +2 -24
- package/dist/index.js +396 -1880
- package/dist/queue/index.d.ts +10 -0
- package/dist/queue/types.d.ts +5 -9
- package/package.json +4 -5
- package/dist/ai/provider.d.ts +0 -45
- package/dist/ai/stream.d.ts +0 -13
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -178
- package/dist/core/cookie.d.ts +0 -36
- package/dist/core/env.d.ts +0 -69
- package/dist/core/html.d.ts +0 -34
- package/dist/core/sse.d.ts +0 -47
- package/dist/middleware/csrf.d.ts +0 -31
- package/dist/middleware/flash.d.ts +0 -44
- package/dist/middleware/health.d.ts +0 -24
- package/dist/middleware/i18n.d.ts +0 -39
- package/dist/middleware/request-id.d.ts +0 -40
- package/dist/middleware/theme.d.ts +0 -31
- package/dist/middleware/validate.d.ts +0 -32
- package/dist/react/index.js +0 -2573
- package/dist/test/test-utils.d.ts +0 -193
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { Context, Middleware } from '../types.ts';
|
|
2
|
-
declare module '../types.ts' {
|
|
3
|
-
interface Context {
|
|
4
|
-
requestId: string;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
/** Options for {@link requestId}. */
|
|
8
|
-
/** Request ID module — a {@link Middleware} that injects `ctx.requestId`. */
|
|
9
|
-
export type RequestIdModule = Middleware<Context, Context & {
|
|
10
|
-
requestId: string;
|
|
11
|
-
}>;
|
|
12
|
-
export interface RequestIdOptions {
|
|
13
|
-
/** Header name for request ID (default: `'X-Request-ID'`). */
|
|
14
|
-
header?: string;
|
|
15
|
-
/** Custom ID generator (default: `crypto.randomUUID`). */
|
|
16
|
-
generator?: () => string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Request ID middleware.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated Use `trace()` from 'weifuwu' instead — it injects `ctx.trace.requestId`
|
|
22
|
-
* along with `traceId` and `elapsed()` in a single middleware.
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* // Old:
|
|
26
|
-
* app.use(requestId())
|
|
27
|
-
* ctx.requestId
|
|
28
|
-
*
|
|
29
|
-
* // New:
|
|
30
|
-
* app.use(trace())
|
|
31
|
-
* ctx.trace.requestId
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* Reads an incoming `X-Request-ID` header (or custom header name) from the
|
|
35
|
-
* request. If absent, generates a new UUID. Sets the response header and
|
|
36
|
-
* injects `ctx.requestId`.
|
|
37
|
-
*/
|
|
38
|
-
export declare function requestId(options?: RequestIdOptions): Middleware<Context, Context & {
|
|
39
|
-
requestId: string;
|
|
40
|
-
}>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Router } from '../core/router.ts';
|
|
2
|
-
import type { Context, Middleware } from '../types.ts';
|
|
3
|
-
declare module '../types.ts' {
|
|
4
|
-
interface Context {
|
|
5
|
-
theme: ThemeInjected;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export interface ThemeInjected {
|
|
9
|
-
value: string;
|
|
10
|
-
set: (value: string, loc?: string) => Response;
|
|
11
|
-
}
|
|
12
|
-
export interface ThemeOptions {
|
|
13
|
-
/** Default theme value (default: 'system'). */
|
|
14
|
-
default?: string;
|
|
15
|
-
/** Cookie name (default: 'theme'). Set to empty string to disable cookie. */
|
|
16
|
-
cookie?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Theme module. Returns a Router with an attached `.middleware()` method.
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* const t = theme()
|
|
23
|
-
* app.use(t.middleware()) // → ctx.theme = { value, set }
|
|
24
|
-
* app.mount('/', t) // → GET /__theme/dark (switch route)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export interface ThemeModule extends Router {
|
|
28
|
-
/** Middleware that injects `ctx.theme = { value, set }`. */
|
|
29
|
-
middleware: () => Middleware<Context, Context & ThemeInjected>;
|
|
30
|
-
}
|
|
31
|
-
export declare function theme(options?: ThemeOptions): ThemeModule;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ZodSchema } from 'zod';
|
|
2
|
-
import type { Middleware } from '../types.ts';
|
|
3
|
-
declare module '../types.ts' {
|
|
4
|
-
interface Context {
|
|
5
|
-
parsed: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
/** Validation middleware — a {@link Middleware} that injects `ctx.parsed` with validated data. */
|
|
9
|
-
export type ValidateModule = Middleware;
|
|
10
|
-
export interface ValidationSchemas {
|
|
11
|
-
body?: ZodSchema;
|
|
12
|
-
query?: ZodSchema;
|
|
13
|
-
params?: ZodSchema;
|
|
14
|
-
headers?: ZodSchema;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Request validation middleware using Zod schemas.
|
|
18
|
-
*
|
|
19
|
-
* Validates `params`, `query`, `body`, and/or `headers` against schemas.
|
|
20
|
-
* Returns 422 with error details on mismatch.
|
|
21
|
-
* Injects `ctx.parsed` with validated-and-transformed values.
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { z } from 'zod'
|
|
25
|
-
*
|
|
26
|
-
* app.get('/users/:id', validate({
|
|
27
|
-
* params: z.object({ id: z.string() }),
|
|
28
|
-
* query: z.object({ include: z.string().optional() }),
|
|
29
|
-
* }), handler)
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function validate(schemas?: ValidationSchemas): Middleware;
|