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-03-04 04:17:42 +08:00
|
|
|
import {Config} from '../../common/config/private/Config';
|
2019-02-15 07:25:55 +08:00
|
|
|
|
|
|
|
export class PersonRouter {
|
|
|
|
public static route(app: Express) {
|
|
|
|
|
2019-03-04 04:17:42 +08:00
|
|
|
this.updatePerson(app);
|
2019-03-11 03:57:27 +08:00
|
|
|
this.addGetPersons(app);
|
2019-02-15 07:25:55 +08:00
|
|
|
this.getPersonThumbnail(app);
|
|
|
|
}
|
|
|
|
|
2019-03-04 04:17:42 +08:00
|
|
|
|
|
|
|
private static updatePerson(app: Express) {
|
|
|
|
app.post(['/api/person/:name'],
|
|
|
|
// common part
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(Config.Client.Faces.writeAccessMinRole),
|
|
|
|
VersionMWs.injectGalleryVersion,
|
|
|
|
|
|
|
|
// specific part
|
|
|
|
PersonMWs.updatePerson,
|
|
|
|
RenderingMWs.renderResult
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-03-11 03:57:27 +08:00
|
|
|
private static addGetPersons(app: Express) {
|
2019-02-15 07:25:55 +08:00
|
|
|
app.get(['/api/person'],
|
2019-03-03 17:30:12 +08:00
|
|
|
// common part
|
2019-02-15 07:25:55 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
2019-02-16 00:47:09 +08:00
|
|
|
VersionMWs.injectGalleryVersion,
|
2019-03-03 17:30:12 +08:00
|
|
|
|
|
|
|
// specific part
|
2019-02-15 07:25:55 +08:00
|
|
|
PersonMWs.listPersons,
|
2019-03-03 17:30:12 +08:00
|
|
|
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'],
|
2019-03-03 17:30:12 +08:00
|
|
|
// common part
|
2019-02-15 07:25:55 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
2019-02-16 00:47:09 +08:00
|
|
|
VersionMWs.injectGalleryVersion,
|
2019-03-03 17:30:12 +08:00
|
|
|
|
|
|
|
// specific part
|
2019-02-15 07:25:55 +08:00
|
|
|
PersonMWs.getSamplePhoto,
|
|
|
|
ThumbnailGeneratorMWs.generatePersonThumbnail,
|
|
|
|
RenderingMWs.renderFile
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|