Files
immich-power-tools/src/helpers/user.helper.ts
T
2024-09-04 19:56:31 +05:30

21 lines
518 B
TypeScript

import { ENV } from "@/config/environment"
import { IUser } from "@/types/user"
export const getUserHeaders = (user: IUser, otherHeaders?: {
'Content-Type': string
}) => {
let headers: {
'Content-Type': string;
'x-api-key'?: string;
'Authorization'?: string
} = {
'Content-Type': 'application/json',
}
if (user.isUsingAPIKey) {
headers['x-api-key'] = ENV.IMMICH_API_KEY
}
else {
headers['Authorization'] = `Bearer ${user.accessToken}`
}
return {...headers, ...otherHeaders}
}