1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Reverted GalleryRouter, did not change it

This commit is contained in:
grasdk 2024-02-16 19:53:58 +01:00
parent 5e94220d6d
commit e1e70fc13c

View File

@ -1,286 +1,286 @@
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs'; import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
import {Express} from 'express'; import {Express} from 'express';
import {GalleryMWs} from '../middlewares/GalleryMWs'; import {GalleryMWs} from '../middlewares/GalleryMWs';
import {RenderingMWs} from '../middlewares/RenderingMWs'; import {RenderingMWs} from '../middlewares/RenderingMWs';
import {ThumbnailGeneratorMWs} from '../middlewares/thumbnail/ThumbnailGeneratorMWs'; import {ThumbnailGeneratorMWs} from '../middlewares/thumbnail/ThumbnailGeneratorMWs';
import {UserRoles} from '../../common/entities/UserDTO'; import {UserRoles} from '../../common/entities/UserDTO';
import {ThumbnailSourceType} from '../model/fileaccess/PhotoWorker'; import {ThumbnailSourceType} from '../model/fileaccess/PhotoWorker';
import {VersionMWs} from '../middlewares/VersionMWs'; import {VersionMWs} from '../middlewares/VersionMWs';
import {SupportedFormats} from '../../common/SupportedFormats'; import {SupportedFormats} from '../../common/SupportedFormats';
import {ServerTimingMWs} from '../middlewares/ServerTimingMWs'; import {ServerTimingMWs} from '../middlewares/ServerTimingMWs';
import {MetaFileMWs} from '../middlewares/MetaFileMWs'; import {MetaFileMWs} from '../middlewares/MetaFileMWs';
import {Config} from '../../common/config/private/Config'; import {Config} from '../../common/config/private/Config';
export class GalleryRouter { export class GalleryRouter {
public static route(app: Express): void { public static route(app: Express): void {
this.addGetImageIcon(app); this.addGetImageIcon(app);
this.addGetVideoIcon(app); this.addGetVideoIcon(app);
this.addGetResizedPhoto(app); this.addGetResizedPhoto(app);
this.addGetBestFitVideo(app); this.addGetBestFitVideo(app);
this.addGetVideoThumbnail(app); this.addGetVideoThumbnail(app);
this.addGetImage(app); this.addGetImage(app);
this.addGetVideo(app); this.addGetVideo(app);
this.addGetMetaFile(app); this.addGetMetaFile(app);
this.addGetBestFitMetaFile(app); this.addGetBestFitMetaFile(app);
this.addRandom(app); this.addRandom(app);
this.addDirectoryList(app); this.addDirectoryList(app);
this.addDirectoryZip(app); this.addDirectoryZip(app);
this.addSearch(app); this.addSearch(app);
this.addAutoComplete(app); this.addAutoComplete(app);
} }
protected static addDirectoryList(app: Express): void { protected static addDirectoryList(app: Express): void {
app.get( app.get(
[Config.Server.apiPath + '/gallery/content/:directory(*)', Config.Server.apiPath + '/gallery/', Config.Server.apiPath + '/gallery//'], [Config.Server.apiPath + '/gallery/content/:directory(*)', Config.Server.apiPath + '/gallery/', Config.Server.apiPath + '/gallery//'],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('directory'), AuthenticationMWs.normalizePathParam('directory'),
AuthenticationMWs.authorisePath('directory', true), AuthenticationMWs.authorisePath('directory', true),
VersionMWs.injectGalleryVersion, VersionMWs.injectGalleryVersion,
// specific part // specific part
GalleryMWs.listDirectory, GalleryMWs.listDirectory,
ThumbnailGeneratorMWs.addThumbnailInformation, ThumbnailGeneratorMWs.addThumbnailInformation,
GalleryMWs.cleanUpGalleryResults, GalleryMWs.cleanUpGalleryResults,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderResult RenderingMWs.renderResult
); );
} }
protected static addDirectoryZip(app: Express): void { protected static addDirectoryZip(app: Express): void {
app.get( app.get(
[Config.Server.apiPath + '/gallery/zip/:directory(*)'], [Config.Server.apiPath + '/gallery/zip/:directory(*)'],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('directory'), AuthenticationMWs.normalizePathParam('directory'),
AuthenticationMWs.authorisePath('directory', true), AuthenticationMWs.authorisePath('directory', true),
// specific part // specific part
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
GalleryMWs.zipDirectory GalleryMWs.zipDirectory
); );
} }
protected static addGetImage(app: Express): void { protected static addGetImage(app: Express): void {
app.get( app.get(
[ [
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Photos.join('|') + SupportedFormats.Photos.join('|') +
'))', '))',
], ],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetVideo(app: Express): void { protected static addGetVideo(app: Express): void {
app.get( app.get(
[ [
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Videos.join('|') + SupportedFormats.Videos.join('|') +
'))', '))',
], ],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetBestFitVideo(app: Express): void { protected static addGetBestFitVideo(app: Express): void {
app.get( app.get(
[ [
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Videos.join('|') + SupportedFormats.Videos.join('|') +
'))/bestFit', '))/bestFit',
], ],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
GalleryMWs.loadBestFitVideo, GalleryMWs.loadBestFitVideo,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetMetaFile(app: Express): void { protected static addGetMetaFile(app: Express): void {
app.get( app.get(
[ [
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.MetaFiles.join('|') + SupportedFormats.MetaFiles.join('|') +
'))', '))',
], ],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetBestFitMetaFile(app: Express): void { protected static addGetBestFitMetaFile(app: Express): void {
app.get( app.get(
[ [
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.MetaFiles.join('|') + SupportedFormats.MetaFiles.join('|') +
'))/bestFit', '))/bestFit',
], ],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
MetaFileMWs.compressGPX, MetaFileMWs.compressGPX,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addRandom(app: Express): void { protected static addRandom(app: Express): void {
app.get( app.get(
[Config.Server.apiPath + '/gallery/random/:searchQueryDTO'], [Config.Server.apiPath + '/gallery/random/:searchQueryDTO'],
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.Guest), AuthenticationMWs.authorise(UserRoles.Guest),
VersionMWs.injectGalleryVersion, VersionMWs.injectGalleryVersion,
// specific part // specific part
GalleryMWs.getRandomImage, GalleryMWs.getRandomImage,
GalleryMWs.loadFile, GalleryMWs.loadFile,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
/** /**
* Used for serving photo thumbnails and previews * Used for serving photo thumbnails and previews
* @param app * @param app
* @protected * @protected
*/ */
protected static addGetResizedPhoto(app: Express): void { protected static addGetResizedPhoto(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Photos.join('|') + SupportedFormats.Photos.join('|') +
'))/:size', '))/:size',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ThumbnailGeneratorMWs.generateThumbnailFactory(ThumbnailSourceType.Photo), ThumbnailGeneratorMWs.generateThumbnailFactory(ThumbnailSourceType.Photo),
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetVideoThumbnail(app: Express): void { protected static addGetVideoThumbnail(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Videos.join('|') + SupportedFormats.Videos.join('|') +
'))/:size?', '))/:size?',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ThumbnailGeneratorMWs.generateThumbnailFactory(ThumbnailSourceType.Video), ThumbnailGeneratorMWs.generateThumbnailFactory(ThumbnailSourceType.Video),
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetVideoIcon(app: Express): void { protected static addGetVideoIcon(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Videos.join('|') + SupportedFormats.Videos.join('|') +
'))/icon', '))/icon',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ThumbnailGeneratorMWs.generateIconFactory(ThumbnailSourceType.Video), ThumbnailGeneratorMWs.generateIconFactory(ThumbnailSourceType.Video),
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addGetImageIcon(app: Express): void { protected static addGetImageIcon(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' + Config.Server.apiPath + '/gallery/content/:mediaPath(*.(' +
SupportedFormats.Photos.join('|') + SupportedFormats.Photos.join('|') +
'))/icon', '))/icon',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.normalizePathParam('mediaPath'), AuthenticationMWs.normalizePathParam('mediaPath'),
AuthenticationMWs.authorisePath('mediaPath', false), AuthenticationMWs.authorisePath('mediaPath', false),
// specific part // specific part
GalleryMWs.loadFile, GalleryMWs.loadFile,
ThumbnailGeneratorMWs.generateIconFactory(ThumbnailSourceType.Photo), ThumbnailGeneratorMWs.generateIconFactory(ThumbnailSourceType.Photo),
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderFile RenderingMWs.renderFile
); );
} }
protected static addSearch(app: Express): void { protected static addSearch(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/search/:searchQueryDTO(*)', Config.Server.apiPath + '/search/:searchQueryDTO(*)',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.Guest), AuthenticationMWs.authorise(UserRoles.Guest),
VersionMWs.injectGalleryVersion, VersionMWs.injectGalleryVersion,
// specific part // specific part
GalleryMWs.search, GalleryMWs.search,
ThumbnailGeneratorMWs.addThumbnailInformation, ThumbnailGeneratorMWs.addThumbnailInformation,
GalleryMWs.cleanUpGalleryResults, GalleryMWs.cleanUpGalleryResults,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderResult RenderingMWs.renderResult
); );
} }
protected static addAutoComplete(app: Express): void { protected static addAutoComplete(app: Express): void {
app.get( app.get(
Config.Server.apiPath + '/autocomplete/:text(*)', Config.Server.apiPath + '/autocomplete/:text(*)',
// common part // common part
AuthenticationMWs.authenticate, AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.Guest), AuthenticationMWs.authorise(UserRoles.Guest),
VersionMWs.injectGalleryVersion, VersionMWs.injectGalleryVersion,
// specific part // specific part
GalleryMWs.autocomplete, GalleryMWs.autocomplete,
ServerTimingMWs.addServerTiming, ServerTimingMWs.addServerTiming,
RenderingMWs.renderResult RenderingMWs.renderResult
); );
} }
} }