immich-public-proxy/dist/immich.js

35 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-10-28 04:56:11 -04:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
class Immich {
request(endpoint_1) {
return tslib_1.__awaiter(this, arguments, void 0, function* (endpoint, json = true) {
const res = yield fetch(process.env.IMMICH_URL + '/api' + endpoint, {
headers: {
'x-api-key': process.env.API_KEY || ''
}
});
if (json) {
return res.json();
}
else {
return res;
}
});
}
getShareByKey(key) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const links = yield this.request('/shared-links');
return links.find(x => x.key === key);
});
}
getImage(id_1) {
return tslib_1.__awaiter(this, arguments, void 0, function* (id, size = 'original') {
size = size === 'thumbnail' ? 'thumbnail' : 'original';
return this.request('/assets/' + id + '/' + size, false);
});
}
}
const api = new Immich();
exports.default = api;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxNQUFNLE1BQU07SUFDSixPQUFPO3FFQUFFLFFBQWdCLEVBQUUsSUFBSSxHQUFHLElBQUk7WUFDMUMsTUFBTSxHQUFHLEdBQUcsTUFBTSxLQUFLLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLEdBQUcsTUFBTSxHQUFHLFFBQVEsRUFBRTtnQkFDbEUsT0FBTyxFQUFFO29CQUNQLFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sSUFBSSxFQUFFO2lCQUN2QzthQUNGLENBQUMsQ0FBQTtZQUNGLElBQUksSUFBSSxFQUFFLENBQUM7Z0JBQ1QsT0FBTyxHQUFHLENBQUMsSUFBSSxFQUFFLENBQUE7WUFDbkIsQ0FBQztpQkFBTSxDQUFDO2dCQUNOLE9BQU8s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