diff --git a/dist/immich.js b/dist/immich.js index 259d24c..07e3148 100644 --- a/dist/immich.js +++ b/dist/immich.js @@ -29,6 +29,7 @@ class Immich { /** * Query Immich for the SharedLink metadata for a given key. * The key is what is returned in the URL when you create a share in Immich. + * * Immich doesn't have a method to query by key, so this method gets all * known shared links, and returns the link which matches the provided key. */ @@ -50,6 +51,7 @@ class Immich { } /** * Stream asset buffer data from Immich. + * * For photos, you can request 'thumbnail' or 'original' size. * For videos, it is Immich's streaming quality, not the original quality. */ @@ -100,4 +102,4 @@ class Immich { } const immich = new Immich(); exports.default = immich; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1taWNoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ltbWljaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxtQ0FBaUU7QUFDakUsMERBQXlCO0FBRXpCLE1BQU0sTUFBTTtJQUNWOzs7T0FHRztJQUNHLE9BQU8sQ0FBRSxRQUFnQjs7WUFDN0IsTUFBTSxHQUFHLEdBQUcsTUFBTSxLQUFLLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxVQUFVLEdBQUcsTUFBTSxHQUFHLFFBQVEsRUFBRTtnQkFDbEUsT0FBTyxFQUFFO29CQUNQLFdBQVcsRUFBRSxPQUFPLENBQUMsR0FBRyxDQUFDLE9BQU8sSUFBSSxFQUFFO2lCQUN2QzthQUNGLENBQUMsQ0FBQTtZQUNGLElBQUksR0FBRyxDQUFDLE1BQU0sS0FBSyxHQUFHLEVBQUUsQ0FBQztnQkFDdkIsTUFBTSxXQUFXLEdBQUcsR0FBRyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSxDQUFBO2dCQUN6RCxJQUFJLFdBQVcsQ0FBQyxRQUFRLENBQUMsa0JBQWtCLENBQUMsRUFBRSxDQUFDO29CQUM3QyxP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mcsIGlkOiBzdHJpbmcsIHNpemU/OiBJbWFnZVNpemUpIHtcbiAgICByZXR1cm4gYC9waG90by8ke2tleX0vJHtpZH1gICsgKHNpemUgPyBgP3NpemU9JHtzaXplfWAgOiAnJylcbiAgfVxuXG4gIC8qKlxuICAgKiBSZXR1cm4gdGhlIHZpZGVvIGRhdGEgVVJMIGZvciBhIHZpZGVvXG4gICAqL1xuICB2aWRlb1VybCAoa2V5OiBzdHJpbmcsIGlkOiBzdHJpbmcpIHtcbiAgICByZXR1cm4gYC92aWRlby8ke2tleX0vJHtpZH1gXG4gIH1cblxuICAvKipcbiAgICogQ2hlY2sgaWYgYSBwcm92aWRlZCBJRCBtYXRjaGVzIHRoZSBJbW1pY2ggSUQgZm9ybWF0XG4gICAqL1xuICBpc0lkIChpZDogc3RyaW5nKSB7XG4gICAgcmV0dXJuICEhaWQubWF0Y2goL15bMC05YS1mXXs4fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXs0fS1bMC05YS1mXXsxMn0kLylcbiAgfVxuXG4gIC8qKlxuICAgKiBDaGVjayBpZiBhIHByb3ZpZGVkIGtleSBtYXRjaGVzIHRoZSBJbW1pY2ggc2hhcmVkLWxpbmsga2V5IGZvcm1hdFxuICAgKi9cbiAgaXNLZXkgKGtleTogc3RyaW5nKSB7XG4gICAgcmV0dXJuICEha2V5Lm1hdGNoKC9eW1xcdy1dKyQvKVxuICB9XG59XG5cbmNvbnN0IGltbWljaCA9IG5ldyBJbW1pY2goKVxuXG5leHBvcnQgZGVmYXVsdCBpbW1pY2hcbiJdfQ== \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 6b14de3..2a0323d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14,14 +14,21 @@ 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; }; +const log = (message) => console.log((0, dayjs_1.default)().format() + ' ' + message); 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)) { + log('Invalid share key ' + req.params.key); res.status(404).send(); } else { const sharedLink = yield immich_1.default.getShareByKey(req.params.key); - if (!sharedLink || !sharedLink.assets.length) { + if (!sharedLink) { + log('Unknown share key ' + req.params.key); + res.status(404).send(); + } + else if (!sharedLink.assets.length) { + log('No assets for key ' + req.params.key); res.status(404).send(); } else if (sharedLink.assets.length === 1) { @@ -59,13 +66,15 @@ app.get('/:type(photo|video)/:key/:id', (req, res) => tslib_1.__awaiter(void 0, } } } + log('No asset found for ' + req.path); res.status(404).send(); })); // Send a 404 for all other unmatched routes -app.get('*', (_req, res) => { +app.get('*', (req, res) => { + log('Invalid route ' + req.path); res.status(404).send(); }); app.listen(3000, () => { console.log((0, dayjs_1.default)().format() + ' Server started'); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsOERBQTZCO0FBQzdCLDhEQUE2QjtBQUM3Qiw4REFBNkI7QUFDN0IsMERBQXlCO0FBQ3pCLG1DQUE4QztBQUc5QyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUMsTUFBTSxFQUFFLENBQUE7QUFFMUIsTUFBTSxHQUFHLEdBQUcsSUFBQSxpQkFBTyxHQUFFLENBQUE7QUFDckIsR0FBRyxDQUFDLEdBQUcsQ0FBQyxhQUFhLEVBQUUsS0FBSyxDQUFDLENBQUE7QUFDN0IsR0FBRyxDQUFDLEdBQUcsQ0FBQyxpQkFBTyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFBO0FBRWpDLE1BQU0sT0FBTyx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hdGNoZWQgcm91dGVzXG5hcHAuZ2V0KCcqJywgKHJlcSwgcmVzKSA9PiB7XG4gIGxvZygnSW52YWxpZCByb3V0ZSAnICsgcmVxLnBhdGgpXG4gIHJlcy5zdGF0dXMoNDA0KS5zZW5kKClcbn0pXG5cbmFwcC5saXN0ZW4oMzAwMCwgKCkgPT4ge1xuICBjb25zb2xlLmxvZyhkYXlqcygpLmZvcm1hdCgpICsgJyBTZXJ2ZXIgc3RhcnRlZCcpXG59KVxuIl19 \ No newline at end of file diff --git a/dist/render.js b/dist/render.js index c4bf711..564dc9f 100644 --- a/dist/render.js +++ b/dist/render.js @@ -20,6 +20,13 @@ class Render { } }); } + /** + * Render a gallery page for a given SharedLink, using EJS and lightGallery. + * + * @param res - ExpressJS Response + * @param share - Immich `shared-link` containing the assets to show in the gallery + * @param [openItem] - Immediately open a lightbox to the Nth item when the gallery loads + */ gallery(res, share, openItem) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const items = []; @@ -55,4 +62,4 @@ class Render { } const render = new Render(); exports.default = render; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVuZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3JlbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4REFBNkI7QUFFN0IsbUNBQWlFO0FBQ2pFLDBEQUF5QjtBQUV6QixNQUFNLE1BQU07SUFDSixXQUFXLENBQUUsR0FBYSxFQUFFLEtBQVksRUFBRSxJQUFnQjs7WUFDOUQsTUFBTSxJQUFJLEdBQUcsTUFBTSxnQkFBTSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDckQsSUFBSSxJQUFJLEVBQUUsQ0FBQztnQkFDVCxLQUFLLE1BQU0sTUFBTSxJQUFJLENBQUMsY0FBYyxFQUFFLGdCQUFnQixDQUFDLEVBQUUsQ0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XG4gICAgICAgICAgXSxcbiAgICAgICAgICBhdHRyaWJ1dGVzOiB7XG4gICAgICAgICAgICBwcmVsb2FkOiBmYWxzZSxcbiAgICAgICAgICAgIGNvbnRyb2xzOiB0cnVlXG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgfVxuICAgICAgaXRlbXMucHVzaCh7XG4gICAgICAgIG9yaWdpbmFsVXJsOiBpbW1pY2gucGhvdG9Vcmwoc2hhcmUua2V5LCBhc3NldC5pZCksXG4gICAgICAgIHRodW1ibmFpbFVybDogaW1taWNoLnBob3RvVXJsKHNoYXJlLmtleSwgYXNzZXQuaWQsIEltYWdlU2l6ZS50aHVtYm5haWwpLFxuICAgICAgICB2aWRlb1xuICAgICAgfSlcbiAgICB9XG4gICAgcmVzLnJlbmRlcignZ2FsbGVyeScsIHtcbiAgICAgIGl0ZW1zLFxuICAgICAgb3Blbkl0ZW1cbiAgICB9KVxuICB9XG59XG5cbmNvbnN0IHJlbmRlciA9IG5ldyBSZW5kZXIoKVxuXG5leHBvcnQgZGVmYXVsdCByZW5kZXJcbiJdfQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVuZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3JlbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4REFBNkI7QUFFN0IsbUNBQWlFO0FBQ2pFLDBEQUF5QjtBQUV6QixNQUFNLE1BQU07SUFDSixXQUFXLENBQUUsR0FBYSxFQUFFLEtBQVksRUFBRSxJQUFnQjs7WUFDOUQsTUFBTSxJQUFJLEdBQUcsTUFBTSxnQkFBTSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDckQsSUFBSSxJQUFJLEVBQUUsQ0FBQztnQkFDVCxLQUFLLE1BQU0sTUFBTSxJQUFJLENBQUMsY0FBYy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\ No newline at end of file diff --git a/src/index.ts b/src/index.ts index aeb741c..cb4f66e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,13 +15,20 @@ const getSize = (req: Request) => { return req?.query?.size === 'thumbnail' ? ImageSize.thumbnail : ImageSize.original } +const log = (message: string) => console.log(dayjs().format() + ' ' + message) + app.get('/share/:key', async (req, res) => { res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE) if (!immich.isKey(req.params.key)) { + log('Invalid share key ' + req.params.key) res.status(404).send() } else { const sharedLink = await immich.getShareByKey(req.params.key) - if (!sharedLink || !sharedLink.assets.length) { + if (!sharedLink) { + log('Unknown share key ' + req.params.key) + res.status(404).send() + } else if (!sharedLink.assets.length) { + 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) @@ -57,11 +64,13 @@ app.get('/:type(photo|video)/:key/:id', async (req, res) => { } } } + log('No asset found for ' + req.path) res.status(404).send() }) // Send a 404 for all other unmatched routes -app.get('*', (_req, res) => { +app.get('*', (req, res) => { + log('Invalid route ' + req.path) res.status(404).send() })