Skip to content

Commit

Permalink
Merge branch 'honojs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronware authored Jul 9, 2024
2 parents 660ffb8 + 61cd9b6 commit dc7f154
Show file tree
Hide file tree
Showing 106 changed files with 4,312 additions and 999 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-event-emitter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci-event-emitter
on:
push:
branches: [main]
paths:
- 'packages/event-emitter/**'
pull_request:
branches: ['*']
paths:
- 'packages/event-emitter/**'

jobs:
ci:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/event-emitter
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
2 changes: 1 addition & 1 deletion .github/workflows/ci-hello.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
25 changes: 25 additions & 0 deletions .github/workflows/ci-node-ws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: ci-node-ws
on:
push:
branches: [main]
paths:
- 'packages/node-ws/**'
pull_request:
branches: ['*']
paths:
- 'packages/node-ws/**'

jobs:
ci:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/node-ws
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
"build:typia-validator": "yarn workspace @hono/typia-validator build",
"build:swagger-ui": "yarn workspace @hono/swagger-ui build",
"build:esbuild-transpiler": "yarn workspace @hono/esbuild-transpiler build",
"build:event-emitter": "yarn workspace @hono/event-emitter build",
"build:oauth-providers": "yarn workspace @hono/oauth-providers build",
"build:react-renderer": "yarn workspace @hono/react-renderer build",
"build:auth-js": "yarn workspace @hono/auth-js build",
"build:bun-transpiler": "yarn workspace @hono/bun-transpiler build",
"build:prometheus": "yarn workspace @hono/prometheus build",
"build:oidc-auth": "yarn workspace @hono/oidc-auth build",
"build:node-ws": "yarn workspace @hono/node-ws build",
"build:react-compat": "yarn workspace @hono/react-compat build",
"build": "run-p 'build:*'",
"lint": "eslint 'packages/**/*.{ts,tsx}'",
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
Expand Down
10 changes: 10 additions & 0 deletions packages/arktype-validator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @hono/arktype-validator

## 2.0.0

### Major Changes

- [#542](https://github.com/honojs/middleware/pull/542) [`c05e5456cb10b6a61df8a203d11f5588b696e824`](https://github.com/honojs/middleware/commit/c05e5456cb10b6a61df8a203d11f5588b696e824) Thanks [@ssalbdivad](https://github.com/ssalbdivad)! - Migrate to ArkType 2.0

If you're still using `arktype-1.x`, you should remain on `@hono/[email protected]`.

If you're using `arktype-2.x` (latest), you'll need to upgrade to `@hono/[email protected]`.

## 1.0.0

### Major Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/arktype-validator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hono/arktype-validator",
"version": "1.0.0",
"version": "2.0.0",
"description": "ArkType validator middleware",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -31,11 +31,11 @@
},
"homepage": "https://github.com/honojs/middleware",
"peerDependencies": {
"arktype": "^1.0.28-alpha",
"arktype": "^2.0.0-dev.14",
"hono": "*"
},
"devDependencies": {
"arktype": "^1.0.28-alpha",
"arktype": "^2.0.0-dev.14",
"hono": "^3.11.7",
"tsup": "^8.0.1",
"vitest": "^1.0.4"
Expand Down
19 changes: 10 additions & 9 deletions packages/arktype-validator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import type { Type, Problems } from 'arktype'
import { type, type Type, type ArkErrors } from 'arktype'
import type { Context, MiddlewareHandler, Env, ValidationTargets, TypedResponse } from 'hono'
import { validator } from 'hono/validator'

export type Hook<T, E extends Env, P extends string, O = {}> = (
result: { success: false; data: unknown; problems: Problems } | { success: true; data: T },
result: { success: false; data: unknown; errors: ArkErrors } | { success: true; data: T },
c: Context<E, P>
) => Response | Promise<Response> | void | Promise<Response | void> | TypedResponse<O>

type HasUndefined<T> = undefined extends T ? true : false

export const arktypeValidator = <
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends Type<any>,
T extends Type,
Target extends keyof ValidationTargets,
E extends Env,
P extends string,
Expand All @@ -30,11 +29,13 @@ export const arktypeValidator = <
hook?: Hook<T['infer'], E, P>
): MiddlewareHandler<E, P, V> =>
validator(target, (value, c) => {
const { data, problems } = schema(value)
const out = schema(value)

const hasErrors = out instanceof type.errors

if (hook) {
const hookResult = hook(
problems ? { success: false, data: value, problems } : { success: true, data },
hasErrors ? { success: false, data: value, errors: out } : { success: true, data: out },
c
)
if (hookResult) {
Expand All @@ -47,15 +48,15 @@ export const arktypeValidator = <
}
}

if (problems) {
if (hasErrors) {
return c.json(
{
success: false,
problems: problems.map((problem) => ({ ...problem, message: problem.toString() })),
errors: out,
},
400
)
}

return data
return out
})
42 changes: 42 additions & 0 deletions packages/auth-js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# @hono/auth-js

## 1.0.10

### Patch Changes

- [#614](https://github.com/honojs/middleware/pull/614) [`19f3beae1ab33bb3257694c742d1b3e5487a187d`](https://github.com/honojs/middleware/commit/19f3beae1ab33bb3257694c742d1b3e5487a187d) Thanks [@divyam234](https://github.com/divyam234)! - fix immutable headers error in x-forwarded req

## 1.0.9

### Patch Changes

- [#598](https://github.com/honojs/middleware/pull/598) [`eb7e597aaabce2b2ac6e7809579c44f440c2b8b0`](https://github.com/honojs/middleware/commit/eb7e597aaabce2b2ac6e7809579c44f440c2b8b0) Thanks [@divyam234](https://github.com/divyam234)! - fix bun req cloning

## 1.0.8

### Patch Changes

- [#549](https://github.com/honojs/middleware/pull/549) [`d5ebee9c70b5c6e9ecdcadd39805a6a7c481c0ee`](https://github.com/honojs/middleware/commit/d5ebee9c70b5c6e9ecdcadd39805a6a7c481c0ee) Thanks [@divyam234](https://github.com/divyam234)! - handle x-forwarded headers to detect auth url

## 1.0.7

### Patch Changes

- [#494](https://github.com/honojs/middleware/pull/494) [`300ef2f8bf4761b7b005e0c4ee7cb6ccf3ef810b`](https://github.com/honojs/middleware/commit/300ef2f8bf4761b7b005e0c4ee7cb6ccf3ef810b) Thanks [@divyam234](https://github.com/divyam234)! - fix for ssr

## 1.0.6

### Patch Changes

- [#486](https://github.com/honojs/middleware/pull/486) [`18959557f45851a0109a63de3e865329c30d4fcc`](https://github.com/honojs/middleware/commit/18959557f45851a0109a63de3e865329c30d4fcc) Thanks [@yusukebe](https://github.com/yusukebe)! - fix: use `env` in `hono/adapter` and add tests

## 1.0.5

### Patch Changes

- [#481](https://github.com/honojs/middleware/pull/481) [`b8fb9a06c13c3d5988b21e1b286c2a0b5ba99d80`](https://github.com/honojs/middleware/commit/b8fb9a06c13c3d5988b21e1b286c2a0b5ba99d80) Thanks [@DIYgod](https://github.com/DIYgod)! - fix AUTH_URL not working in getAuthUser

## 1.0.4

### Patch Changes

- [#478](https://github.com/honojs/middleware/pull/478) [`5004ca9c5b6f75c1fca001c26fc70b927c154589`](https://github.com/honojs/middleware/commit/5004ca9c5b6f75c1fca001c26fc70b927c154589) Thanks [@DIYgod](https://github.com/DIYgod)! - fix env AUTH_URL not working

## 1.0.3

### Patch Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/auth-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ AUTH_URL=#optional
## How to Use

```ts
import { Hono,Context } from 'hono'
import { authHandler, initAuthConfig, verifyAuth, AuthConfig } from "@hono/auth-js"
import { Hono, Context } from 'hono'
import { authHandler, initAuthConfig, verifyAuth, type AuthConfig } from "@hono/auth-js"
import GitHub from "@auth/core/providers/github"

const app = new Hono()

Expand Down
4 changes: 2 additions & 2 deletions packages/auth-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hono/auth-js",
"version": "1.0.3",
"version": "1.0.10",
"description": "A third-party Auth js middleware for Hono",
"main": "dist/index.js",
"exports": {
Expand Down Expand Up @@ -57,7 +57,7 @@
"react": ">=18"
},
"devDependencies": {
"@auth/core": "^0.24.0",
"@auth/core": "^0.30.0",
"@types/react": "^18",
"hono": "^3.11.7",
"jest": "^29.7.0",
Expand Down
Loading

0 comments on commit dc7f154

Please sign in to comment.