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

85 lines
2.7 KiB
TypeScript
Raw Normal View History

2016-05-26 02:17:42 +08:00
import {AuthenticationMWs} from "../middlewares/user/AuthenticationMWs";
2016-03-20 02:59:19 +08:00
import {GalleryMWs} from "../middlewares/GalleryMWs";
import {RenderingMWs} from "../middlewares/RenderingMWs";
import {ThumbnailGeneratorMWs} from "../middlewares/thumbnail/ThumbnailGeneratorMWs";
2016-05-09 23:04:56 +08:00
export class GalleryRouter {
2017-06-04 21:25:08 +08:00
public static route(app: any) {
2017-06-04 21:25:08 +08:00
this.addGetImageIcon(app);
this.addGetImageThumbnail(app);
this.addGetImage(app);
this.addDirectoryList(app);
2017-06-04 21:25:08 +08:00
this.addSearch(app);
this.addInstantSearch(app);
this.addAutoComplete(app);
}
2017-06-04 21:25:08 +08:00
private static addDirectoryList(app) {
app.get(["/api/gallery/content/:directory(*)", "/api/gallery/", "/api/gallery//"],
2016-05-13 05:00:38 +08:00
AuthenticationMWs.authenticate,
GalleryMWs.listDirectory,
ThumbnailGeneratorMWs.addThumbnailInformation,
GalleryMWs.removeCyclicDirectoryReferences,
RenderingMWs.renderResult
);
};
2017-06-04 21:25:08 +08:00
private static addGetImage(app) {
app.get(["/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))"],
2016-03-20 23:54:30 +08:00
AuthenticationMWs.authenticate,
GalleryMWs.loadImage,
RenderingMWs.renderFile
);
};
2017-06-04 21:25:08 +08:00
private static addGetImageThumbnail(app) {
app.get("/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/thumbnail/:size?",
2016-03-20 02:59:19 +08:00
AuthenticationMWs.authenticate,
2016-03-30 03:46:44 +08:00
GalleryMWs.loadImage,
ThumbnailGeneratorMWs.generateThumbnail,
RenderingMWs.renderFile
);
};
2017-06-04 21:25:08 +08:00
private static addGetImageIcon(app) {
app.get("/api/gallery/content/:imagePath(*\.(jpg|bmp|png|gif|jpeg))/icon",
AuthenticationMWs.authenticate,
GalleryMWs.loadImage,
ThumbnailGeneratorMWs.generateIcon,
RenderingMWs.renderFile
);
};
2017-06-04 21:25:08 +08:00
private static addSearch(app) {
app.get("/api/search/:text",
2016-05-17 01:36:04 +08:00
AuthenticationMWs.authenticate,
GalleryMWs.search,
ThumbnailGeneratorMWs.addThumbnailInformation,
GalleryMWs.removeCyclicDirectoryReferences,
RenderingMWs.renderResult
);
};
2017-06-04 21:25:08 +08:00
private static addInstantSearch(app) {
app.get("/api/instant-search/:text",
AuthenticationMWs.authenticate,
GalleryMWs.instantSearch,
ThumbnailGeneratorMWs.addThumbnailInformation,
GalleryMWs.removeCyclicDirectoryReferences,
RenderingMWs.renderResult
);
};
2017-06-04 21:25:08 +08:00
private static addAutoComplete(app) {
app.get("/api/autocomplete/:text",
2016-05-16 17:03:11 +08:00
AuthenticationMWs.authenticate,
GalleryMWs.autocomplete,
RenderingMWs.renderResult
);
};
}