Skip to content

Commit 345442a

Browse files
add example
1 parent 5fdd220 commit 345442a

File tree

19 files changed

+1609
-2
lines changed

19 files changed

+1609
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const app = new Elysia()
4545
notFoundError(),
4646

4747
// Skip handling Elysia's validation and parse errors in this middleware,
48-
// allowing Elysia's default behavior (or other plugins) to handle them.
48+
// allowing Elysia's default behavior to handle them.
4949
ignoreValidationAndParseError(),
5050

5151
// 2. Custom Logging (Optional)
@@ -80,7 +80,7 @@ Creates the plugin. Accepts an array of error handlers that are executed in orde
8080
- `nextJsError()`: Checks for Next.js internal errors (redirects, `notFound()`) and re-throws them so Next.js can handle them. **Must be placed early in the chain.**
8181
- `apiError()`: Catches `APIError` instances and returns a structured JSON response `{ success: false, message, code }`.
8282
- `notFoundError()`: Catches Elysia's `NotFoundError` and calls Next.js `notFound()`.
83-
- `ignoreValidationAndParseError()`: Ignores Elysia's validation and parse errors so they can be handled by other handlers or default behavior.
83+
- `ignoreValidationAndParseError()`: Ignores Elysia's validation and parse errors, allowing Elysia's default behavior to handle them.
8484
- `internalServerError()`: Logs the error and returns a generic 500 response.
8585

8686
### `APIError`

example/.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts

example/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

example/biome.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.0/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": true,
10+
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "space",
15+
"indentWidth": 2
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true,
21+
"suspicious": {
22+
"noUnknownAtRules": "off"
23+
}
24+
},
25+
"domains": {
26+
"next": "recommended",
27+
"react": "recommended"
28+
}
29+
},
30+
"assist": {
31+
"actions": {
32+
"source": {
33+
"organizeImports": "on"
34+
}
35+
}
36+
}
37+
}

example/next.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
/* config options here */
4+
experimental: {
5+
},
6+
typescript: {
7+
ignoreBuildErrors: true,
8+
},
9+
};
10+
11+
export default nextConfig;

example/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "biome check",
10+
"format": "biome format --write"
11+
},
12+
"dependencies": {
13+
"elysia": "^1.4.17",
14+
"elysia-next-error-handler": "file:..",
15+
"next": "14.2.3",
16+
"react": "^18",
17+
"react-dom": "^18"
18+
},
19+
"devDependencies": {
20+
"@biomejs/biome": "2.2.0",
21+
"@tailwindcss/postcss": "^4",
22+
"@types/node": "^20",
23+
"@types/react": "^19",
24+
"@types/react-dom": "^19",
25+
"babel-plugin-react-compiler": "1.0.0",
26+
"tailwindcss": "^4",
27+
"typescript": "^5"
28+
}
29+
}

0 commit comments

Comments
 (0)