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';
|
2019-02-16 00:47:09 +08:00
|
|
|
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'],
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
2019-02-16 00:47:09 +08:00
|
|
|
VersionMWs.injectGalleryVersion,
|
2019-02-15 07:25:55 +08:00
|
|
|
PersonMWs.listPersons,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static getPersonThumbnail(app: Express) {
|
|
|
|
app.get(['/api/person/:name/thumbnail'],
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
2019-02-16 00:47:09 +08:00
|
|
|
VersionMWs.injectGalleryVersion,
|
2019-02-15 07:25:55 +08:00
|
|
|
PersonMWs.getSamplePhoto,
|
|
|
|
ThumbnailGeneratorMWs.generatePersonThumbnail,
|
|
|
|
RenderingMWs.renderFile
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|