Skip to content

Commit 2bcf0f3

Browse files
schplittHugoRCD
andauthored
feat: add support for nitro v3 (#8)
Co-authored-by: Hugo Richard <hugo.richard@vercel.com>
1 parent c0b32ad commit 2bcf0f3

62 files changed

Lines changed: 2574 additions & 645 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.data
44
.nuxt
55
.nitro
6+
.vinxi
67
.cache
78
dist
89

@@ -31,4 +32,5 @@ logs
3132
.workflow-data*
3233
apps/web/.data
3334
apps/chat/.data
34-
.codex/environments/
35+
.codex/environments/
36+
.claude/

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,43 @@ The wide event emitted at the end contains **everything**:
176176

177177
Works with **any framework powered by Nitro**: Nuxt, Analog, Vinxi, SolidStart, TanStack Start, and more.
178178

179+
### Nitro v3
180+
179181
```typescript
180182
// nitro.config.ts
183+
import { defineConfig } from 'nitro'
184+
import evlog from 'evlog/nitro/v3'
185+
186+
export default defineConfig({
187+
modules: [
188+
evlog({ env: { service: 'my-api' } })
189+
],
190+
})
191+
```
192+
193+
### Nitro v2
194+
195+
```typescript
196+
// nitro.config.ts
197+
import { defineNitroConfig } from 'nitropack/config'
198+
import evlog from 'evlog/nitro'
199+
181200
export default defineNitroConfig({
182-
plugins: ['evlog/nitro'],
201+
modules: [
202+
evlog({ env: { service: 'my-api' } })
203+
],
183204
})
184205
```
185206

186-
Same API, same wide events:
207+
Then use `useLogger` in any route. Import from `evlog/nitro/v3` (v3) or `evlog/nitro` (v2):
187208

188209
```typescript
189210
// routes/api/documents/[id]/export.post.ts
190-
import { useLogger, createError } from 'evlog'
211+
// Nitro v3: import { defineHandler } from 'nitro/h3' + import { useLogger } from 'evlog/nitro/v3'
212+
// Nitro v2: import { defineEventHandler } from 'h3' + import { useLogger } from 'evlog/nitro'
213+
import { defineEventHandler } from 'h3'
214+
import { useLogger } from 'evlog/nitro'
215+
import { createError } from 'evlog'
191216

192217
export default defineEventHandler(async (event) => {
193218
const log = useLogger(event)
@@ -833,11 +858,12 @@ evlog works with any framework powered by [Nitro](https://nitro.unjs.io/):
833858
| Framework | Integration |
834859
|-----------|-------------|
835860
| **Nuxt** | `modules: ['evlog/nuxt']` |
836-
| **Analog** | `plugins: ['evlog/nitro']` |
837-
| **Vinxi** | `plugins: ['evlog/nitro']` |
838-
| **SolidStart** | `plugins: ['evlog/nitro']` |
839-
| **TanStack Start** | `plugins: ['evlog/nitro']` |
840-
| **Standalone Nitro** | `plugins: ['evlog/nitro']` |
861+
| **Nitro v3** | `modules: [evlog()]` with `import evlog from 'evlog/nitro/v3'` |
862+
| **Nitro v2** | `modules: [evlog()]` with `import evlog from 'evlog/nitro'` |
863+
| **Analog** | Nitro v2 module setup |
864+
| **Vinxi** | Nitro v2 module setup |
865+
| **SolidStart** | Nitro v2 module setup ([example](./examples/solidstart)) |
866+
| **TanStack Start** | Nitro v2 module setup |
841867

842868
## Agent Skills
843869

apps/docs/content/1.getting-started/1.introduction.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ Structured errors provide actionable context:
111111
::code-group
112112
```typescript [Code]
113113
// server/api/checkout.post.ts
114+
import { createError } from 'evlog'
115+
114116
throw createError({
115117
message: 'Payment failed',
116118
status: 402,

0 commit comments

Comments
 (0)