2016-03-20 00:31:42 +08:00
|
|
|
///<reference path="../../typings/main.d.ts"/>
|
|
|
|
|
|
|
|
import {AuthenticationMWs} from "../middlewares/AuthenticationMWs";
|
2016-03-20 02:59:19 +08:00
|
|
|
import {GalleryMWs} from "../middlewares/GalleryMWs";
|
2016-03-26 18:19:10 +08:00
|
|
|
import {RenderingMWs} from "../middlewares/RenderingMWs";
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
export class GalleryRouter{
|
|
|
|
constructor(private app){
|
|
|
|
|
|
|
|
this.addDirectoryList();
|
|
|
|
this.addGetImageThumbnail();
|
|
|
|
this.addGetImage();
|
|
|
|
|
|
|
|
this.addSearch();
|
|
|
|
this.addAutoComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private addDirectoryList() {
|
2016-03-26 23:25:48 +08:00
|
|
|
this.app.get(["/api/gallery/:directory","/api/gallery/","/api/gallery//"],
|
2016-03-20 23:54:30 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.listDirectory,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private addGetImage() {
|
2016-03-20 17:49:49 +08:00
|
|
|
this.app.get(["/api/gallery/:directory/:image","/api/gallery/:image"],
|
2016-03-20 23:54:30 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.loadImage,
|
|
|
|
RenderingMWs.renderFile
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private addGetImageThumbnail() {
|
|
|
|
this.app.get("/api/gallery/:directory/:image/thumbnail",
|
2016-03-20 02:59:19 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.loadThumbnail,
|
|
|
|
RenderingMWs.renderFile
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private addSearch() {
|
|
|
|
this.app.get("/api/gallery/search",
|
2016-03-20 02:59:19 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.search,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private addAutoComplete() {
|
|
|
|
this.app.get("/api/gallery/autocomplete",
|
2016-03-20 02:59:19 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2016-03-26 18:19:10 +08:00
|
|
|
GalleryMWs.autocomplete,
|
|
|
|
RenderingMWs.renderResult
|
2016-03-20 00:31:42 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|