@pyreon/zero 0.24.4 → 0.24.6

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.
Files changed (54) hide show
  1. package/package.json +10 -39
  2. package/src/actions.ts +0 -196
  3. package/src/adapters/bun.ts +0 -114
  4. package/src/adapters/cloudflare.ts +0 -166
  5. package/src/adapters/index.ts +0 -61
  6. package/src/adapters/netlify.ts +0 -154
  7. package/src/adapters/node.ts +0 -163
  8. package/src/adapters/static.ts +0 -42
  9. package/src/adapters/validate.ts +0 -23
  10. package/src/adapters/vercel.ts +0 -182
  11. package/src/adapters/warn-missing-env.ts +0 -49
  12. package/src/ai.ts +0 -623
  13. package/src/api-routes.ts +0 -219
  14. package/src/app.ts +0 -92
  15. package/src/cache.ts +0 -136
  16. package/src/client.ts +0 -143
  17. package/src/compression.ts +0 -116
  18. package/src/config.ts +0 -35
  19. package/src/cors.ts +0 -94
  20. package/src/csp.ts +0 -226
  21. package/src/entry-server.ts +0 -224
  22. package/src/env.ts +0 -344
  23. package/src/error-overlay.ts +0 -118
  24. package/src/favicon.ts +0 -841
  25. package/src/font.ts +0 -511
  26. package/src/fs-router.ts +0 -1519
  27. package/src/i18n-routing.ts +0 -533
  28. package/src/icon.tsx +0 -182
  29. package/src/icons-plugin.ts +0 -296
  30. package/src/image-plugin.ts +0 -751
  31. package/src/image-types.ts +0 -60
  32. package/src/image.tsx +0 -340
  33. package/src/index.ts +0 -92
  34. package/src/isr.ts +0 -394
  35. package/src/link.tsx +0 -304
  36. package/src/logger.ts +0 -144
  37. package/src/manifest.ts +0 -787
  38. package/src/meta.tsx +0 -354
  39. package/src/middleware.ts +0 -65
  40. package/src/not-found.ts +0 -44
  41. package/src/og-image.ts +0 -378
  42. package/src/rate-limit.ts +0 -140
  43. package/src/script.tsx +0 -260
  44. package/src/seo.ts +0 -617
  45. package/src/server.ts +0 -89
  46. package/src/sharp.d.ts +0 -22
  47. package/src/ssg-plugin.ts +0 -1582
  48. package/src/testing.ts +0 -146
  49. package/src/theme.tsx +0 -257
  50. package/src/types.ts +0 -624
  51. package/src/utils/use-intersection-observer.ts +0 -36
  52. package/src/utils/with-headers.ts +0 -13
  53. package/src/vercel-revalidate-handler.ts +0 -204
  54. package/src/vite-plugin.ts +0 -848
package/src/logger.ts DELETED
@@ -1,144 +0,0 @@
1
- /**
2
- * Request logging middleware.
3
- *
4
- * Logs HTTP requests with method, path, status, and duration.
5
- * Supports custom formatters and log levels.
6
- *
7
- * @example
8
- * ```ts
9
- * import { loggerMiddleware } from "@pyreon/zero"
10
- *
11
- * export default defineConfig({
12
- * middleware: [loggerMiddleware()],
13
- * })
14
- * ```
15
- */
16
- import type { Middleware, MiddlewareContext } from '@pyreon/server'
17
-
18
- export interface LoggerConfig {
19
- /**
20
- * Log level — controls which requests are logged.
21
- * - "all": log every request
22
- * - "none": disable logging
23
- * Default: "all"
24
- */
25
- level?: 'all' | 'none'
26
- /**
27
- * Custom log formatter. Receives request details and returns
28
- * the string to log (or null to skip).
29
- */
30
- format?: (entry: LogEntry) => string | null
31
- /**
32
- * Skip logging for these path prefixes.
33
- * Default: ["/__", "/@", "/node_modules"]
34
- */
35
- skip?: string[]
36
- /**
37
- * Enable colorized output (ANSI codes).
38
- * Default: true in development, false in production.
39
- */
40
- colors?: boolean
41
- }
42
-
43
- export interface LogEntry {
44
- method: string
45
- path: string
46
- duration: number
47
- timestamp: Date
48
- userAgent?: string | undefined
49
- ip?: string | undefined
50
- }
51
-
52
- const COLORS = {
53
- reset: '\x1b[0m',
54
- dim: '\x1b[2m',
55
- green: '\x1b[32m',
56
- yellow: '\x1b[33m',
57
- red: '\x1b[31m',
58
- cyan: '\x1b[36m',
59
- magenta: '\x1b[35m',
60
- }
61
-
62
- function methodColor(method: string, colors: boolean): string {
63
- if (!colors) return method.padEnd(7)
64
- const padded = method.padEnd(7)
65
- switch (method) {
66
- case 'GET': return `${COLORS.green}${padded}${COLORS.reset}`
67
- case 'POST': return `${COLORS.cyan}${padded}${COLORS.reset}`
68
- case 'PUT': return `${COLORS.yellow}${padded}${COLORS.reset}`
69
- case 'PATCH': return `${COLORS.yellow}${padded}${COLORS.reset}`
70
- case 'DELETE': return `${COLORS.red}${padded}${COLORS.reset}`
71
- default: return `${COLORS.magenta}${padded}${COLORS.reset}`
72
- }
73
- }
74
-
75
- function defaultFormat(entry: LogEntry, colors: boolean): string {
76
- const dur = entry.duration < 1
77
- ? '<1ms'
78
- : entry.duration < 1000
79
- ? `${Math.round(entry.duration)}ms`
80
- : `${(entry.duration / 1000).toFixed(2)}s`
81
-
82
- const dim = colors ? COLORS.dim : ''
83
- const reset = colors ? COLORS.reset : ''
84
-
85
- return ` ${methodColor(entry.method, colors)} ${entry.path} ${dim}${dur}${reset}`
86
- }
87
-
88
- /**
89
- * Request logging middleware.
90
- *
91
- * Logs incoming requests with method, path, and duration.
92
- * Runs in middleware phase — logs timing from middleware start to
93
- * microtask completion (approximate request duration).
94
- *
95
- * @example
96
- * ```ts
97
- * // Basic usage
98
- * loggerMiddleware()
99
- *
100
- * // Custom format
101
- * loggerMiddleware({
102
- * format: (e) => `${e.method} ${e.path} (${e.duration}ms)`,
103
- * })
104
- * ```
105
- */
106
- export function loggerMiddleware(config?: LoggerConfig): Middleware {
107
- const level = config?.level ?? 'all'
108
- if (level === 'none') return () => {}
109
-
110
- const skip = config?.skip ?? ['/__', '/@', '/node_modules']
111
- const isDev = typeof process !== 'undefined' && process.env.NODE_ENV !== 'production'
112
- const colors = config?.colors ?? isDev
113
-
114
- return (ctx: MiddlewareContext) => {
115
- // Skip internal paths
116
- if (skip.some((p) => ctx.path.startsWith(p))) return
117
-
118
- const start = performance.now()
119
-
120
- const entry: LogEntry = {
121
- method: ctx.req.method ?? 'GET',
122
- path: ctx.path,
123
- duration: 0,
124
- timestamp: new Date(),
125
- userAgent: ctx.req.headers.get('user-agent') ?? undefined,
126
- }
127
-
128
- // Use queueMicrotask to log after the middleware chain completes
129
- queueMicrotask(() => {
130
- entry.duration = performance.now() - start
131
-
132
- if (config?.format) {
133
- const line = config.format(entry)
134
- if (line) {
135
- // oxlint-disable-next-line no-console
136
- console.log(line)
137
- }
138
- } else {
139
- // oxlint-disable-next-line no-console
140
- console.log(defaultFormat(entry, colors))
141
- }
142
- })
143
- }
144
- }