mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-09 23:48:36 +01:00
27 lines
883 B
TypeScript
27 lines
883 B
TypeScript
|
|
export type CustomOptions = {
|
|
useSnapshotDates?: boolean,
|
|
useActivePid?: boolean,
|
|
slice?: string,
|
|
}
|
|
|
|
const { token } = useAccessToken();
|
|
const { projectId } = useProject();
|
|
const { safeSnapshotDates } = useSnapshot()
|
|
|
|
export function useComputedHeaders(customOptions?: CustomOptions) {
|
|
const useSnapshotDates = customOptions?.useSnapshotDates || true;
|
|
const useActivePid = customOptions?.useActivePid || true;
|
|
|
|
const headers = computed<Record<string, string>>(() => {
|
|
return {
|
|
'Authorization': `Bearer ${token.value}`,
|
|
'x-pid': useActivePid ? (projectId.value ?? '') : '',
|
|
'x-from': useSnapshotDates ? (safeSnapshotDates.value.from ?? '') : '',
|
|
'x-to': useSnapshotDates ? (safeSnapshotDates.value.to ?? '') : '',
|
|
'x-slice': customOptions?.slice ?? ''
|
|
}
|
|
})
|
|
|
|
return headers;
|
|
} |