chore: format (includes other middleware)

pull/552/head
Ame_x 2024-05-29 03:40:21 +00:00
parent ef318bef47
commit 16b4462014
5 changed files with 20 additions and 12 deletions

View File

@ -66,7 +66,6 @@ export interface SignOutParams<R extends boolean = true> {
redirect?: R redirect?: R
} }
export interface SessionProviderProps { export interface SessionProviderProps {
children: React.ReactNode children: React.ReactNode
session?: Session | null session?: Session | null
@ -136,11 +135,11 @@ export function now() {
} }
export function parseUrl(url?: string) { export function parseUrl(url?: string) {
const defaultUrl = 'http://localhost:3000/api/auth'; const defaultUrl = 'http://localhost:3000/api/auth'
const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl); const parsedUrl = new URL(url?.startsWith('http') ? url : `https://${url}` || defaultUrl)
const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, ''); const path = parsedUrl.pathname === '/' ? '/api/auth' : parsedUrl.pathname.replace(/\/$/, '')
const base = `${parsedUrl.origin}${path}`; const base = `${parsedUrl.origin}${path}`
return { return {
origin: parsedUrl.origin, origin: parsedUrl.origin,
@ -148,5 +147,5 @@ export function parseUrl(url?: string) {
path, path,
base, base,
toString: () => base, toString: () => base,
}; }
} }

View File

@ -192,8 +192,8 @@ describe('Credentials Provider', () => {
it('Should respect x-forwarded-proto and x-forwarded-host', async () => { it('Should respect x-forwarded-proto and x-forwarded-host', async () => {
const headers = new Headers() const headers = new Headers()
headers.append('x-forwarded-proto', "https") headers.append('x-forwarded-proto', 'https')
headers.append('x-forwarded-host', "example.com") headers.append('x-forwarded-host', 'example.com')
const res = await app.request('http://localhost/api/auth/signin', { const res = await app.request('http://localhost/api/auth/signin', {
headers, headers,
}) })

View File

@ -1,6 +1,15 @@
import { Hono } from 'hono' import { Hono } from 'hono'
import type { Equal, Expect } from 'hono/utils/types' import type { Equal, Expect } from 'hono/utils/types'
import { number, object, string, optional, numberAsync, objectAsync, stringAsync, optionalAsync } from 'valibot' import {
number,
object,
string,
optional,
numberAsync,
objectAsync,
stringAsync,
optionalAsync,
} from 'valibot'
import { vValidator } from '../src' import { vValidator } from '../src'
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars