1
0
Fork 0
mirror of https://github.com/alangrainger/immich-public-proxy.git synced 2024-12-29 12:21:57 +00:00
immich-public-proxy/dist/index.js
2024-10-30 20:07:15 +01:00

94 lines
No EOL
13 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = void 0;
const tslib_1 = require("tslib");
const express_1 = tslib_1.__importDefault(require("express"));
const immich_1 = tslib_1.__importDefault(require("./immich"));
const render_1 = tslib_1.__importDefault(require("./render"));
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
const types_1 = require("./types");
require('dotenv').config();
const app = (0, express_1.default)();
// Add the EJS view engine, to render the gallery page
app.set('view engine', 'ejs');
// Serve static assets from the /public folder
app.use(express_1.default.static('public'));
// An incoming request for a shared link
app.get('/share/:key', (req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE);
if (!immich_1.default.isKey(req.params.key)) {
(0, exports.log)('Invalid share key ' + req.params.key);
res.status(404).send();
}
else {
const sharedLink = yield immich_1.default.getShareByKey(req.params.key);
if (!sharedLink) {
(0, exports.log)('Unknown share key ' + req.params.key);
res.status(404).send();
}
else if (!sharedLink.assets.length) {
(0, exports.log)('No assets for key ' + req.params.key);
res.status(404).send();
}
else if (sharedLink.assets.length === 1) {
// This is an individual item (not a gallery)
(0, exports.log)('Serving link ' + req.params.key);
const asset = sharedLink.assets[0];
if (asset.type === types_1.AssetType.image) {
// For photos, output the image directly
yield render_1.default.assetBuffer(res, sharedLink.assets[0], getSize(req));
}
else if (asset.type === types_1.AssetType.video) {
// For videos, show the video as a web player
yield render_1.default.gallery(res, sharedLink, 1);
}
}
else {
// Multiple images - render as a gallery
(0, exports.log)('Serving link ' + req.params.key);
yield render_1.default.gallery(res, sharedLink);
}
}
}));
// Output the buffer data for a photo or video
app.get('/:type(photo|video)/:key/:id', (req, res) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE);
// Check for valid key and ID
if (immich_1.default.isKey(req.params.key) && immich_1.default.isId(req.params.id)) {
// Check if the key is a valid share link
const sharedLink = yield immich_1.default.getShareByKey(req.params.key);
if (sharedLink === null || sharedLink === void 0 ? void 0 : sharedLink.assets.length) {
// Check that the requested asset exists in this share
const asset = sharedLink.assets.find(x => x.id === req.params.id);
if (asset) {
asset.type = req.params.type === 'video' ? types_1.AssetType.video : types_1.AssetType.image;
render_1.default.assetBuffer(res, asset, getSize(req)).then();
return;
}
}
}
(0, exports.log)('No asset found for ' + req.path);
res.status(404).send();
}));
// Send a 404 for all other routes
app.get('*', (req, res) => {
(0, exports.log)('Invalid route ' + req.path);
res.status(404).send();
});
/**
* Sanitise the data for an incoming query string `size` parameter
* e.g. https://example.com/share/abc...xyz?size=thumbnail
*/
const getSize = (req) => {
var _a;
return ((_a = req === null || req === void 0 ? void 0 : req.query) === null || _a === void 0 ? void 0 : _a.size) === 'thumbnail' ? types_1.ImageSize.thumbnail : types_1.ImageSize.original;
};
/**
* Output a console.log message with timestamp
*/
const log = (message) => console.log((0, dayjs_1.default)().format() + ' ' + message);
exports.log = log;
app.listen(3000, () => {
console.log((0, dayjs_1.default)().format() + ' Server started');
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLDhEQUE2QjtBQUM3Qiw4REFBNkI7QUFDN0IsOERBQTZCO0FBQzdCLDBEQUF5QjtBQUN6QixtQ0FBOEM7QUFHOUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDLE1BQU0sRUFBRSxDQUFBO0FBRTFCLE1BQU0sR0FBRyxHQUFHLElBQUEsaUJBQU8sR0FBRSxDQUFBO0FBQ3JCLHNEQUFzRDtBQUN0RCxHQUFHLENBQUMsR0FBRy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