1
0
Fork 0
mirror of https://github.com/alangrainger/immich-public-proxy.git synced 2024-12-29 12:21:57 +00:00

Add additional logging

This commit is contained in:
Alan Grainger 2024-10-30 14:28:29 +01:00
parent 48f3403543
commit 1566f7abe4
4 changed files with 34 additions and 7 deletions

4
dist/immich.js vendored

File diff suppressed because one or more lines are too long

15
dist/index.js vendored

File diff suppressed because one or more lines are too long

9
dist/render.js vendored
View file

@ -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) { gallery(res, share, openItem) {
return tslib_1.__awaiter(this, void 0, void 0, function* () { return tslib_1.__awaiter(this, void 0, void 0, function* () {
const items = []; const items = [];
@ -55,4 +62,4 @@ class Render {
} }
const render = new Render(); const render = new Render();
exports.default = render; exports.default = render;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVuZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3JlbmRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw4REFBNkI7QUFFN0IsbUNBQWlFO0FBQ2pFLDBEQUF5QjtBQUV6QixNQUFNLE1BQU07SUFDSixXQUFXLENBQUUsR0FBYSxFQUFFLEtBQVksRUFBRSxJQUFnQjs7WUFDOUQsTUFBTSxJQUFJLEdBQUcsTUFBTSxnQkFBTSxDQUFDLGNBQWMsQ0FBQyxLQUFLLEVBQUUsSUFBSSxDQUFDLENBQUE7WUFDckQsSUFBSSxJQUFJLEVBQUUsQ0FBQztnQkFDVCxLQUFLLE1BQU0sTUFBTSxJQUFJLENBQUMsY0FBYyxFQUFFLGdCQUFnQixDQUFDLEVBQUUsQ0FBQztvQkFDeEQsR0FBRyxDQUFDLEdBQUcsQ0FBQy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IGZvciAoY29uc3QgYXNzZXQgb2Ygc2hhcmUuYXNzZXRzKSB7XG4gICAgICBsZXQgdmlkZW9cbiAgICAgIGlmIChhc3NldC50eXBlID09PSBBc3NldFR5cGUudmlkZW8pIHtcbiAgICAgICAgLy8gUG9wdWxhdGUgdGhlIGRhdGEtdmlkZW8gcHJvcGVydHlcbiAgICAgICAgdmlkZW8gPSBKU09OLnN0cmluZ2lmeSh7XG4gICAgICAgICAgc291cmNlOiBbXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIHNyYzogaW1taWNoLnZpZGVvVXJsKHNoYXJlLmtleSwgYXNzZXQuaWQpLFxuICAgICAgICAgICAgICB0eXBlOiBhd2FpdCBpbW1pY2guZ2V0Q29udGVudFR5cGUoYXNzZXQpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgXSxcbiAgICAgICAgICBhdHRyaWJ1dGVzOiB7XG4gICAgICAgICAgICBwcmVsb2FkOiBmYWxzZSxcbiAgICAgICAgICAgIGNvbnRyb2xzOiB0cnVlXG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgfVxuICAgICAgaXRlbXMucHVzaCh7XG4gICAgICAgIG9yaWdpbmFsVXJsOiBpbW1pY2gucGhvdG9Vcmwoc2hhcmUua2V5LCBhc3NldC5pZCksXG4gICAgICAgIHRodW1ibmFpbFVybDogaW1taWNoLnBob3RvVXJsKHNoYXJlLmtleSwgYXNzZXQuaWQsIEltYWdlU2l6ZS50aHVtYm5haWwpLFxuICAgICAgICB2aWRlb1xuICAgICAgfSlcbiAgICB9XG4gICAgcmVzLnJlbmRlcignZ2FsbGVyeScsIHtcbiAgICAgIGl0ZW1zLFxuICAgICAgb3Blbkl0ZW1cbiAgICB9KVxuICB9XG59XG5cbmNvbnN0IHJlbmRlciA9IG5ldyBSZW5kZXIoKVxuXG5leHBvcnQgZGVmYXVsdCByZW5kZXJcbiJdfQ==

View file

@ -15,13 +15,20 @@ const getSize = (req: Request) => {
return req?.query?.size === 'thumbnail' ? ImageSize.thumbnail : ImageSize.original 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) => { app.get('/share/:key', async (req, res) => {
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE) res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE)
if (!immich.isKey(req.params.key)) { if (!immich.isKey(req.params.key)) {
log('Invalid share key ' + req.params.key)
res.status(404).send() res.status(404).send()
} else { } else {
const sharedLink = await immich.getShareByKey(req.params.key) 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() res.status(404).send()
} else if (sharedLink.assets.length === 1) { } else if (sharedLink.assets.length === 1) {
// This is an individual item (not a gallery) // 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() res.status(404).send()
}) })
// Send a 404 for all other unmatched routes // 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() res.status(404).send()
}) })