1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/backend/routes/GalleryRouter.ts

63 lines
1.7 KiB
TypeScript
Raw Normal View History

///<reference path="../../typings/main.d.ts"/>
import {AuthenticationMWs} from "../middlewares/AuthenticationMWs";
2016-03-19 19:59:19 +01:00
import {GalleryMWs} from "../middlewares/GalleryMWs";
import {RenderingMWs} from "../middlewares/RenderingMWs";
2016-03-29 21:46:44 +02:00
import {ThumbnailGeneratorMWs} from "../middlewares/ThumbnailGeneratorMWs";
export class GalleryRouter{
constructor(private app){
this.addGetImageThumbnail();
this.addGetImage();
2016-03-26 19:24:12 +01:00
this.addDirectoryList();
this.addSearch();
this.addAutoComplete();
}
private addDirectoryList() {
2016-03-26 19:24:12 +01:00
this.app.get(["/api/gallery/:directory(*)","/api/gallery/","/api/gallery//"],
2016-03-20 16:54:30 +01:00
AuthenticationMWs.authenticate,
GalleryMWs.listDirectory,
RenderingMWs.renderResult
);
};
private addGetImage() {
2016-03-26 19:24:12 +01:00
this.app.get(["/api/gallery/:imagePath(*\.(jpg|bmp|png|gif|jpeg))"],
2016-03-20 16:54:30 +01:00
AuthenticationMWs.authenticate,
GalleryMWs.loadImage,
RenderingMWs.renderFile
);
};
private addGetImageThumbnail() {
2016-03-29 21:46:44 +02:00
this.app.get("/api/gallery/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/thumbnail/:size?",
2016-03-19 19:59:19 +01:00
AuthenticationMWs.authenticate,
2016-03-29 21:46:44 +02:00
GalleryMWs.loadImage,
ThumbnailGeneratorMWs.generateThumbnail,
RenderingMWs.renderFile
);
};
private addSearch() {
this.app.get("/api/gallery/search",
2016-03-19 19:59:19 +01:00
AuthenticationMWs.authenticate,
GalleryMWs.search,
RenderingMWs.renderResult
);
};
private addAutoComplete() {
this.app.get("/api/gallery/autocomplete",
2016-03-19 19:59:19 +01:00
AuthenticationMWs.authenticate,
GalleryMWs.autocomplete,
RenderingMWs.renderResult
);
};
}