mirror of
https://github.com/alangrainger/immich-public-proxy.git
synced 2024-12-28 20:01:57 +00:00
27 lines
617 B
JavaScript
27 lines
617 B
JavaScript
class Immich {
|
|
async request (endpoint, json = true) {
|
|
const res = await fetch(process.env.IMMICH_URL + '/api' + endpoint, {
|
|
headers: {
|
|
'x-api-key': process.env.API_KEY
|
|
}
|
|
})
|
|
if (json) {
|
|
return res.json()
|
|
} else {
|
|
return res
|
|
}
|
|
}
|
|
|
|
async getShareByKey (key) {
|
|
const links = await this.request('/shared-links')
|
|
return links.find(x => x.key === key)
|
|
}
|
|
|
|
async getImage (id, size) {
|
|
size = size === 'thumbnail' ? 'thumbnail' : 'original'
|
|
return this.request('/assets/' + id + '/' + size, false)
|
|
}
|
|
}
|
|
|
|
const api = new Immich()
|
|
export default api
|