Skip to content

Commit 1e3268c

Browse files
refactor: rename proxy path getter
1 parent 483bfc4 commit 1e3268c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/runtime/composables/$kirby.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ServerFetchOptions } from '../types'
44
import { useNuxtApp, useRequestFetch, useRuntimeConfig } from '#imports'
55
import { hash } from 'ohash'
66
import { joinURL } from 'ufo'
7-
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
7+
import { buildApiProxyPath, createAuthHeader, headersToObject } from '../utils'
88

99
// #region options
1010
export type KirbyFetchOptions = Pick<
@@ -101,7 +101,7 @@ export function $kirby<T = any>(
101101
body,
102102
}
103103

104-
const request = useRequestFetch()(kql.client ? path : getProxyPath(_key), {
104+
const request = useRequestFetch()(kql.client ? path : buildApiProxyPath(_key), {
105105
...fetchOptions,
106106
...(kql.client ? _clientFetchOptions : _serverFetchOptions),
107107
})

src/runtime/composables/$kql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ModuleOptions } from '../../module'
44
import type { ServerFetchOptions } from '../types'
55
import { useNuxtApp, useRequestFetch, useRuntimeConfig } from '#imports'
66
import { hash } from 'ohash'
7-
import { createAuthHeader, getProxyPath, headersToObject } from '../utils'
7+
import { buildApiProxyPath, createAuthHeader, headersToObject } from '../utils'
88

99
// #region options
1010
export type KqlOptions = Pick<
@@ -86,7 +86,7 @@ export function $kql<T extends KirbyQueryResponse<any, boolean> = KirbyQueryResp
8686
},
8787
}
8888

89-
const request = useRequestFetch()(kql.client ? kql.prefix : getProxyPath(_key), {
89+
const request = useRequestFetch()(kql.client ? kql.prefix : buildApiProxyPath(_key), {
9090
...fetchOptions,
9191
...(kql.client ? _clientFetchOptions : _serverFetchOptions),
9292
})

src/runtime/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import type { ModuleOptions } from '../module'
2-
3-
export function getProxyPath(key: string) {
1+
export function buildApiProxyPath(key: string) {
42
return `/api/__kirby__/${encodeURIComponent(key)}`
53
}
64

@@ -12,7 +10,11 @@ export function createAuthHeader({
1210
auth,
1311
token,
1412
credentials,
15-
}: Pick<ModuleOptions, 'token' | 'credentials'> & { auth?: string }) {
13+
}: {
14+
auth?: string
15+
token?: string
16+
credentials?: { username: string, password: string }
17+
}) {
1618
if (auth === 'basic' && credentials) {
1719
const { username, password } = credentials
1820
const encoded = globalThis.btoa(`${username}:${password}`)

0 commit comments

Comments
 (0)