Skip to content

Commit

Permalink
feat(vite-hono): Add new example project
Browse files Browse the repository at this point in the history
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
ryoppippi committed Jun 1, 2024
1 parent 3989db4 commit 933521a
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 0 deletions.
Binary file modified bun.lockb
Binary file not shown.
33 changes: 33 additions & 0 deletions examples/vite-hono/.gitignore
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
8 changes: 8 additions & 0 deletions examples/vite-hono/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```txt
npm install
npm run dev
```

```txt
npm run deploy
```
26 changes: 26 additions & 0 deletions examples/vite-hono/package.json
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"
}
}
1 change: 1 addition & 0 deletions examples/vite-hono/public/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h1 { font-family: Arial, Helvetica, sans-serif; }
22 changes: 22 additions & 0 deletions examples/vite-hono/src/index.ts
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;
12 changes: 12 additions & 0 deletions examples/vite-hono/src/types.ts
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>();
11 changes: 11 additions & 0 deletions examples/vite-hono/tsconfig.json
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" ],
},
}
15 changes: 15 additions & 0 deletions examples/vite-hono/vite.config.ts
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",
}),
],
});

0 comments on commit 933521a

Please sign in to comment.