1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/routes/PersonRouter.ts

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-02-15 07:25:55 +08:00
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
import {Express} from 'express';
import {RenderingMWs} from '../middlewares/RenderingMWs';
import {UserRoles} from '../../common/entities/UserDTO';
import {PersonMWs} from '../middlewares/PersonMWs';
import {ThumbnailGeneratorMWs} from '../middlewares/thumbnail/ThumbnailGeneratorMWs';
import {VersionMWs} from '../middlewares/VersionMWs';
2019-02-15 07:25:55 +08:00
export class PersonRouter {
public static route(app: Express) {
this.addPersons(app);
this.getPersonThumbnail(app);
}
private static addPersons(app: Express) {
app.get(['/api/person'],
// common part
2019-02-15 07:25:55 +08:00
AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.User),
VersionMWs.injectGalleryVersion,
// specific part
2019-02-15 07:25:55 +08:00
PersonMWs.listPersons,
PersonMWs.addSamplePhotoForAll,
ThumbnailGeneratorMWs.addThumbnailInfoForPersons,
PersonMWs.removeSamplePhotoForAll,
2019-02-15 07:25:55 +08:00
RenderingMWs.renderResult
);
}
private static getPersonThumbnail(app: Express) {
app.get(['/api/person/:name/thumbnail'],
// common part
2019-02-15 07:25:55 +08:00
AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.User),
VersionMWs.injectGalleryVersion,
// specific part
2019-02-15 07:25:55 +08:00
PersonMWs.getSamplePhoto,
ThumbnailGeneratorMWs.generatePersonThumbnail,
RenderingMWs.renderFile
);
}
}