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

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-03-31 03:30:30 +08:00
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
import {UserRoles} from '../../common/entities/UserDTO';
import {RenderingMWs} from '../middlewares/RenderingMWs';
import {SharingMWs} from '../middlewares/SharingMWs';
2016-05-09 23:04:56 +08:00
export class SharingRouter {
public static route(app: any) {
2017-07-09 18:03:17 +08:00
this.addShareLogin(app);
this.addGetSharing(app);
2017-07-04 01:17:49 +08:00
this.addCreateSharing(app);
this.addUpdateSharing(app);
}
2017-07-09 18:03:17 +08:00
private static addShareLogin(app) {
2018-03-31 03:30:30 +08:00
app.post('/api/share/login',
2017-07-09 18:03:17 +08:00
AuthenticationMWs.inverseAuthenticate,
AuthenticationMWs.shareLogin,
RenderingMWs.renderSessionUser
);
};
private static addGetSharing(app) {
2018-03-31 03:30:30 +08:00
app.get('/api/share/:sharingKey',
AuthenticationMWs.authenticate,
2017-07-09 18:03:17 +08:00
AuthenticationMWs.authorise(UserRoles.LimitedGuest),
2017-07-04 01:17:49 +08:00
SharingMWs.getSharing,
RenderingMWs.renderSharing
);
};
private static addCreateSharing(app) {
2018-03-31 03:30:30 +08:00
app.post(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
2017-07-04 01:17:49 +08:00
AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.User),
SharingMWs.createSharing,
RenderingMWs.renderSharing
);
};
private static addUpdateSharing(app) {
2018-03-31 03:30:30 +08:00
app.put(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
AuthenticationMWs.authenticate,
2017-07-04 01:17:49 +08:00
AuthenticationMWs.authorise(UserRoles.User),
SharingMWs.updateSharing,
RenderingMWs.renderSharing
);
};
}