generated from HugoRCD/nuxt-module-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add support for nitro v3 #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
schplitt
wants to merge
32
commits into
HugoRCD:main
Choose a base branch
from
schplitt:feat/nitrov3-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,493
−167
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
85f1c22
feat: add nitrov3 support
schplitt 3fc91f7
chore: add ufo package to dependencies
schplitt d55f967
docs: add note for early Nitro v3 support in installation guide
schplitt e25ae9b
chore: initialize nitrov3 playground
schplitt e6e9445
revert: nitro 2 playground
schplitt 9d005f0
chore: add nitrov3 output to package.json
schplitt 0b1592a
docs: add note for early Nitro v3 support in README
schplitt 6e7727d
chore: better nitro v3 playground
schplitt ef07be7
chore: expose nitro v3 at `nitro/v3`
schplitt 6171d49
chore: update Nitro v3 references to use `evlog/nitro/v3`
schplitt d307849
Merge branch 'main' into feat/nitrov3-support
HugoRCD 0994c10
up
HugoRCD 90e2c45
feat(nitro-v3): align EvlogError with Nitro v3 HTTPError contract
schplitt f6e7b73
Merge remote-tracking branch 'origin/main' into feat/nitrov3-support
schplitt 23c32cd
nitro/v3 feature parity
schplitt 2bd17f6
fix: error handling/logging
schplitt 860568f
Merge remote-tracking branch 'origin/main' into feat/nitrov3-support
schplitt 4d7b5e4
nitrov3 respect exclude config
schplitt 9dbe202
Merge remote-tracking branch 'origin/main' into feat/nitrov3-support
schplitt 3fe2419
feat: nitro v3 feature parity
schplitt 5e2e51d
chore: deps
schplitt da5ff3a
build: add nitro v3 plugin and error handler entries to tsdown config
schplitt 3be516a
test: nitro v3 tests
schplitt 83ecf18
chore: clean up nitro v3 playground
schplitt cd2f9fb
docs: update nitro v3 usage
schplitt 8b1339f
docs: update README for Nitro v3 playground
schplitt 2bb0b09
Merge remote-tracking branch 'origin/main' into feat/nitrov3-support
schplitt fa5f175
build: explicitly inline `ufo`
schplitt 0534fc1
refactor: remove evlog path mappings from playground tsconfig
schplitt 5a5de18
docs: update Nitro v3 plugin and errorHandler registration
schplitt a353be6
refactor: leave unknown errors to default error handler
schplitt 933faee
Merge branch 'main' into feat/nitrov3-support
HugoRCD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| node_modules | ||
| dist | ||
| .data | ||
| .nitro | ||
| .cache | ||
| .output | ||
| .env | ||
| .env.local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Nitro v3 evlog playground | ||
|
|
||
| ## Getting started | ||
|
|
||
| ```bash | ||
| bun install | ||
| bun run dev | ||
| ``` | ||
|
|
||
| ## Deploying | ||
|
|
||
| ```bash | ||
| bun run build | ||
| ``` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from 'evlog/nitro/v3/errorHandler' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { defineConfig } from 'nitro' | ||
|
|
||
| export default defineConfig({ | ||
| serverDir: './', | ||
| errorHandler: './errorHandler', | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "name": "evlog-nitro-v3-playground", | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "nitro build", | ||
| "dev": "nitro dev", | ||
| "preview": "npx srvx --prod .output/" | ||
| }, | ||
| "dependencies": { | ||
| "evlog": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "nitro": "latest", | ||
| "rolldown": "latest" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from 'evlog/nitro/v3' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { defineHandler, readBody } from 'nitro/h3' | ||
| import { useLogger } from 'evlog' | ||
|
|
||
| export default defineHandler(async (event) => { | ||
| const log = useLogger(event) | ||
| const body = await readBody(event) as { name: string; type: string } | ||
|
|
||
| log.set({ user: { id: 456 } }) | ||
| log.set({ item: { name: body.name, type: body.type } }) | ||
|
|
||
| // Simulate validation | ||
| await new Promise(resolve => setTimeout(resolve, 100)) | ||
| log.set({ validation: { passed: true, checks: ['name_length', 'type_valid'] } }) | ||
|
|
||
| // Simulate database insert | ||
| await new Promise(resolve => setTimeout(resolve, 200)) | ||
| const itemId = `item_${Math.random().toString(36).substring(2, 8)}` | ||
| log.set({ database: { operation: 'insert', duration: '200ms' } }) | ||
|
|
||
| // Simulate search indexing | ||
| await new Promise(resolve => setTimeout(resolve, 80)) | ||
| log.set({ search: { indexed: true, engine: 'elasticsearch' } }) | ||
|
|
||
| return { | ||
| success: true, | ||
| message: 'Item created', | ||
| id: itemId, | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { defineHandler } from 'nitro/h3' | ||
| import { useLogger } from 'evlog' | ||
|
|
||
| export default defineHandler(async (event) => { | ||
| const log = useLogger(event) | ||
| const itemId = 'item_123' | ||
|
|
||
| log.set({ user: { id: 789 } }) | ||
| log.set({ action: 'delete_item', itemId }) | ||
|
|
||
| // Simulate permission check | ||
| await new Promise(resolve => setTimeout(resolve, 100)) | ||
| log.set({ permissions: { checked: true, hasDelete: true } }) | ||
|
|
||
| // Simulate database delete | ||
| await new Promise(resolve => setTimeout(resolve, 150)) | ||
| log.set({ database: { operation: 'delete', affected: 1 } }) | ||
|
|
||
| // Simulate cache invalidation | ||
| await new Promise(resolve => setTimeout(resolve, 50)) | ||
| log.set({ cache: { invalidated: true, keys: [`item:${itemId}`] } }) | ||
|
|
||
| return { | ||
| success: true, | ||
| message: 'Item deleted', | ||
| deletedId: itemId, | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { defineHandler } from 'nitro/h3' | ||
| import { useLogger } from 'evlog' | ||
|
|
||
| export default defineHandler(async (event) => { | ||
| const log = useLogger(event) | ||
|
|
||
| log.set({ user: { id: 123, plan: 'pro' } }) | ||
| log.set({ action: 'fetch_profile' }) | ||
|
|
||
| // Simulate database query | ||
| await new Promise(resolve => setTimeout(resolve, 150)) | ||
| const profile = { name: 'John Doe', email: 'john@example.com', lastLogin: new Date().toISOString() } | ||
| log.set({ profile }) | ||
|
|
||
| // Simulate cache check | ||
| await new Promise(resolve => setTimeout(resolve, 50)) | ||
| log.set({ cache: { hit: true, ttl: 3600 } }) | ||
|
|
||
| return { | ||
| success: true, | ||
| message: 'Profile fetched successfully', | ||
| data: profile, | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { defineHandler, readBody } from 'nitro/h3' | ||
| import { useLogger, createError } from 'evlog' | ||
|
|
||
| export default defineHandler(async (event) => { | ||
| const log = useLogger(event) | ||
| const body = await readBody(event) as { name: string; version: string } | ||
|
|
||
| log.set({ user: { id: 999 } }) | ||
| log.set({ action: 'update_item', item: { name: body.name, version: body.version } }) | ||
|
|
||
| // Simulate validation check | ||
| await new Promise(resolve => setTimeout(resolve, 100)) | ||
| log.set({ validation: { checked: true } }) | ||
|
|
||
| // Simulate permission check that always fails | ||
| await new Promise(resolve => setTimeout(resolve, 150)) | ||
| log.set({ permissions: { checked: true, hasUpdate: false, requiredRole: 'admin' } }) | ||
|
|
||
| throw createError({ | ||
| message: 'Update failed', | ||
| status: 403, | ||
| why: 'Insufficient permissions to update this resource', | ||
| fix: 'Request admin privileges or contact your team lead', | ||
| link: 'https://docs.example.com/permissions', | ||
| }) | ||
| }) |
72 changes: 72 additions & 0 deletions
72
apps/nitro-v3-playground/routes/api/test/wide-event.get.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { defineHandler } from 'nitro/h3' | ||
| import { useLogger } from 'evlog' | ||
|
|
||
| export default defineHandler(async (event) => { | ||
| const log = useLogger(event) | ||
|
|
||
| // User context | ||
| await new Promise(resolve => setTimeout(resolve, 80)) | ||
| log.set({ | ||
| user: { | ||
| id: 'user_789', | ||
| email: 'demo@example.com', | ||
| plan: 'enterprise', | ||
| accountAge: '2 years', | ||
| role: 'admin', | ||
| }, | ||
| session: { | ||
| device: 'desktop', | ||
| browser: 'Chrome 120', | ||
| country: 'US', | ||
| }, | ||
| }) | ||
|
|
||
| // Cart information | ||
| await new Promise(resolve => setTimeout(resolve, 80)) | ||
| log.set({ | ||
| cart: { | ||
| items: 5, | ||
| total: 24999, | ||
| currency: 'USD', | ||
| discount: { | ||
| code: 'WINTER25', | ||
| savings: 8333, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| // Payment processing | ||
| await new Promise(resolve => setTimeout(resolve, 80)) | ||
| log.set({ | ||
| payment: { | ||
| method: 'card', | ||
| cardBrand: 'visa', | ||
| cardLast4: '4242', | ||
| }, | ||
| fraud: { | ||
| score: 12, | ||
| riskLevel: 'low', | ||
| passed: true, | ||
| }, | ||
| }) | ||
|
|
||
| // Performance metrics | ||
| await new Promise(resolve => setTimeout(resolve, 80)) | ||
| log.set({ | ||
| performance: { | ||
| dbQueries: 8, | ||
| cacheHits: 12, | ||
| cacheMisses: 2, | ||
| }, | ||
| flags: { | ||
| newCheckoutFlow: true, | ||
| experimentId: 'exp_checkout_v2', | ||
| }, | ||
| }) | ||
|
|
||
| return { | ||
| success: true, | ||
| message: 'Wide event demo - check your terminal!', | ||
| orderId: 'ord_abc123xyz', | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { useLogger } from 'evlog' | ||
| import { defineHandler } from 'nitro/h3' | ||
|
|
||
| export default defineHandler((event) => { | ||
| const log = useLogger(event) | ||
| log.set({ | ||
| playground: 'nitro/v3', | ||
| }) | ||
| return { | ||
| message: 'evlog Nitro v3 Playground', | ||
| endpoints: [ | ||
| 'GET /api/test/success', | ||
| 'POST /api/test/create', | ||
| 'PUT /api/test/update (always fails)', | ||
| 'DELETE /api/test/delete', | ||
| 'GET /api/test/wide-event', | ||
| ], | ||
| } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "extends": ["nitro/tsconfig"], | ||
| "compilerOptions": { | ||
| "moduleResolution": "bundler", | ||
| "paths": { | ||
| "~/*": ["./*"], | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to customize tsconfig? Ideally, I would like the user to have as little to configure as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bun workspaces does not resolve the types correctly.
It doesn't seem to correctly install the evlog package from the workspace on my machine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed