Skip to content

Commit be3b186

Browse files
authored
Merge pull request #8 from sandros94/refactor-and-update
refactor: library,testing,pnpm
2 parents de96f1f + 8560e8f commit be3b186

22 files changed

+7993
-2539
lines changed

.eslintignore

-1
This file was deleted.

.eslintrc

-16
This file was deleted.

.github/workflows/ci.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ name: ci
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
- dev
88
pull_request:
99
branches:
10-
- master
10+
- main
1111
- dev
1212

1313
jobs:
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-latest]
20-
node: [16]
20+
node: [20]
2121

2222
steps:
2323
- uses: actions/setup-node@v1
@@ -31,14 +31,14 @@ jobs:
3131
uses: actions/cache@v1
3232
with:
3333
path: node_modules
34-
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
34+
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/pnpm-lock.yaml')) }}
3535

3636
- name: Install dependencies
3737
if: steps.cache.outputs.cache-hit != 'true'
38-
run: yarn
38+
run: pnpm i
3939

40-
# - name: Lint
41-
# run: yarn lint
40+
- name: Test
41+
run: pnpm test
4242

4343
- name: Build
44-
run: yarn build
44+
run: pnpm build

README.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ yarn add h3-valibot
2121
## Validation
2222

2323
```ts router.ts
24-
import { useValidatedBody } from 'h3-valibot'
24+
import { useValidatedBody, v } from 'h3-valibot'
2525

2626
import { createApp, createRouter, eventHandler } from "h3";
2727
import { email, minLength, string, objectAsync } from 'valibot';
2828

2929
export const app = createApp();
30-
const LoginSchema = objectAsync({
31-
email: string([email()]),
32-
password: string([minLength(8)]),
30+
const LoginSchema = v.object({
31+
email: v.pipe(v.string(), v.email()),
32+
password: v.pipe(v.string(), v.minLength(8)),
3333
});
3434

3535
const router = createRouter();
@@ -49,32 +49,32 @@ h3-valibot throws an `ValiError` when the validation fails:
4949
Exampl
5050
```json
5151
{
52-
"statusCode": 400,
53-
"statusMessage": "Bad Request",
54-
"stack": [],
55-
"data": {
56-
"issues": [
57-
{
58-
"validation": "email",
59-
"origin": "value",
60-
"message": "Invalid email",
61-
"input": "github@conner-bachmande",
62-
"path": [
63-
{
64-
"schema": "object",
65-
"input": {
66-
"email": "github@conner-bachmande",
67-
"password": "12345678"
68-
},
69-
"key": "email",
70-
"value": "github@conner-bachmande"
71-
}
72-
],
73-
"reason": "string"
74-
}
52+
"statusCode": 400,
53+
"statusMessage": "Bad Request",
54+
"stack": [],
55+
"data": {
56+
"issues": [
57+
{
58+
"validation": "email",
59+
"origin": "value",
60+
"message": "Invalid email",
61+
"input": "github@conner-bachmande",
62+
"path": [
63+
{
64+
"schema": "object",
65+
"input": {
66+
"email": "github@conner-bachmande",
67+
"password": "12345678"
68+
},
69+
"key": "email",
70+
"value": "github@conner-bachmande"
71+
}
7572
],
76-
"name": "ValiError"
77-
}
73+
"reason": "string"
74+
}
75+
],
76+
"name": "ValiError"
77+
}
7878
}
7979
```
8080

eslint.config.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import antfu from '@antfu/eslint-config'
2+
3+
export default antfu().append({
4+
ignores: ['README.md'],
5+
})

package.json

+29-22
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
22
"name": "h3-valibot",
3+
"type": "module",
34
"version": "0.0.7",
45
"description": "🤖 Schema validation for h3 using Valibot",
5-
"license": "MIT",
66
"author": "Conner Bachmann <[email protected]>",
7+
"license": "MIT",
8+
"keywords": [
9+
"valibot",
10+
"h3",
11+
"validation"
12+
],
713
"sideEffects": false,
8-
"type": "module",
914
"exports": {
1015
".": {
16+
"types": "./dist/index.d.ts",
1117
"import": "./dist/index.mjs",
12-
"require": "./dist/index.cjs",
13-
"types": "./dist/index.d.ts"
18+
"require": "./dist/index.cjs"
1419
}
1520
},
1621
"main": "./dist/index.cjs",
@@ -19,29 +24,31 @@
1924
"files": [
2025
"dist"
2126
],
22-
"keywords": [
23-
"valibot",
24-
"h3",
25-
"validation"
26-
],
2727
"scripts": {
2828
"build": "unbuild",
29-
"lint": "eslint --ext .ts .",
29+
"dev": "vitest",
30+
"lint": "eslint .",
3031
"release": "yarn build && changelogen --patch && git push --follow-tags && yarn publish",
31-
"typecheck": "tsc --noEmit"
32-
},
33-
"devDependencies": {
34-
"@types/node": "^17.0.23",
35-
"@typescript-eslint/eslint-plugin": "^5.30.5",
36-
"@typescript-eslint/parser": "^5.30.5",
37-
"changelogen": "^0.3.5",
38-
"eslint": "^8.12.0",
39-
"typescript": "^4.6.3",
40-
"unbuild": "^0.7.4",
41-
"vitest": "^0.17.0"
32+
"test": "pnpm lint && pnpm test:types && vitest --run",
33+
"test:types": "tsc --noEmit --skipLibCheck"
4234
},
4335
"dependencies": {
4436
"h3": "^1.13.0",
45-
"valibot": "^0.42.1"
37+
"valibot": "^1.0.0-beta.3"
38+
},
39+
"devDependencies": {
40+
"@antfu/eslint-config": "3.8.0",
41+
"@nuxtjs/eslint-config-typescript": "latest",
42+
"@types/node": "^20",
43+
"@types/serve-handler": "6.1.4",
44+
"@typescript-eslint/eslint-plugin": "8.14.0",
45+
"@typescript-eslint/parser": "8.14.0",
46+
"changelogen": "^0.5.7",
47+
"eslint": "^9.14.0",
48+
"supertest": "^7.0.0",
49+
"typescript": "^5.6.3",
50+
"unbuild": "latest",
51+
"vite": "5.4.10",
52+
"vitest": "^2.1.4"
4653
}
4754
}

playground/app.ts

-26
This file was deleted.

playground/package.json

-13
This file was deleted.

0 commit comments

Comments
 (0)