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

View File

@ -118,7 +118,7 @@ export function authHandler(): MiddlewareHandler {
return async (c) => {
const config = c.get('authConfig')
let ctxEnv = env(c) as AuthEnv
setEnvDefaults(ctxEnv, config)
if (!config.secret || config.secret.length === 0) {
@ -128,4 +128,4 @@ export function authHandler(): MiddlewareHandler {
const res = await Auth(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config)
return new Response(res.body, res)
}
}
}

View File

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

View File

@ -20,7 +20,7 @@ export interface NodeWebSocketInit {
* @returns NodeWebSocket
*/
export const createNodeWebSocket = (init: NodeWebSocketInit): NodeWebSocket => {
const wss = new WebSocketServer({noServer: true})
const wss = new WebSocketServer({ noServer: true })
return {
injectWebSocket(server) {

View File

@ -1,6 +1,15 @@
import { Hono } from 'hono'
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'
// eslint-disable-next-line @typescript-eslint/no-unused-vars