generated from unplugin/unplugin-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vite-hono): Add new example project
This commit introduces a new example project named 'vite-hono'. It includes the setup for a Vite project with Hono, Typia, and Unplugin-Typia. The project includes a basic server setup with Hono, a Typia validation schema, and a Vite configuration with Unplugin-Typia. It also includes necessary scripts and dependencies in package.json, a .gitignore file, and a README with basic instructions.
- Loading branch information
Showing
9 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
# prod | ||
dist/ | ||
|
||
# dev | ||
.yarn/ | ||
!.yarn/releases | ||
.vscode/* | ||
!.vscode/launch.json | ||
!.vscode/*.code-snippets | ||
.idea/workspace.xml | ||
.idea/usage.statistics.xml | ||
.idea/shelf | ||
|
||
# deps | ||
node_modules/ | ||
.wrangler | ||
|
||
# env | ||
.env | ||
.env.production | ||
.dev.vars | ||
|
||
# logs | ||
logs/ | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
# misc | ||
.DS_Store |
This file contains 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 @@ | ||
```txt | ||
npm install | ||
npm run dev | ||
``` | ||
|
||
```txt | ||
npm run deploy | ||
``` |
This file contains 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 @@ | ||
{ | ||
"type": "module", | ||
"private": true, | ||
"name": "vite-hono", | ||
"scripts": { | ||
"dev": "bun -b vite", | ||
"build": "bun -b vite build", | ||
"preview": "bun -b vite dev", | ||
"deploy": "bun -b run build && wrangler pages deploy", | ||
"prepare": "ts-patch install && typia patch" | ||
}, | ||
"dependencies": { | ||
"hono": "^4.4.2", | ||
"uuid": "^9.0.1" | ||
}, | ||
"devDependencies": { | ||
"@hono/typia-validator": "^0.0.4", | ||
"@hono/vite-dev-server": "^0.12.1", | ||
"ts-node": "^10.9.2", | ||
"ts-patch": "^3.1.2", | ||
"typescript": "^5.4.5", | ||
"typia": "^6.0.4", | ||
"unplugin-typia": "workspace:*", | ||
"vite": "^5.2.12" | ||
} | ||
} |
This file contains 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 @@ | ||
h1 { font-family: Arial, Helvetica, sans-serif; } |
This file contains 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,22 @@ | ||
import { Hono } from "hono"; | ||
import { typiaValidator } from "@hono/typia-validator"; | ||
import { validate } from "./types.js"; | ||
|
||
const app = new Hono(); | ||
|
||
app.get("/", (c) => { | ||
return c.json({ | ||
success: true, | ||
message: "Hello World", | ||
}); | ||
}); | ||
|
||
app.post("/", typiaValidator("json", validate), (c) => { | ||
const data = c.req.valid("json"); | ||
return c.json({ | ||
success: true, | ||
message: `${data.name} is ${data.age}`, | ||
}); | ||
}); | ||
|
||
export default app; |
This file contains 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,12 @@ | ||
import typia, { type tags } from "typia"; | ||
|
||
export interface Author { | ||
name: string; | ||
age: | ||
& number | ||
& tags.Type<"uint32"> | ||
& tags.Minimum<20> | ||
& tags.ExclusiveMaximum<100>; | ||
} | ||
|
||
export const validate = typia.createValidate<Author>(); |
This file contains 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,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"lib": [ "ESNext" ], | ||
"types": [ "vite/client" ], | ||
}, | ||
} |
This file contains 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,15 @@ | ||
import devServer from '@hono/vite-dev-server' | ||
import { defineConfig } from "vite"; | ||
import UnpluginTypia from "unplugin-typia"; | ||
|
||
export default defineConfig({ | ||
build: { | ||
minify: false, | ||
}, | ||
plugins: [ | ||
UnpluginTypia.vite(), | ||
devServer({ | ||
entry: "src/index.ts", | ||
}), | ||
], | ||
}); |