|
|
@@ -185,7 +185,7 @@ module.exports = (crowi) => {
|
|
|
const addActivity = generateAddActivityMiddleware(crowi);
|
|
|
|
|
|
const globalNotificationService = crowi.getGlobalNotificationService();
|
|
|
- const { Page } = crowi.models;
|
|
|
+ const Page = mongoose.model<IPage, PageModel>('Page');
|
|
|
const { pageService, exportService } = crowi;
|
|
|
|
|
|
const activityEvent = crowi.event('activity');
|
|
|
@@ -246,6 +246,9 @@ module.exports = (crowi) => {
|
|
|
contentWidth: [
|
|
|
body('expandContentWidth').isBoolean(),
|
|
|
],
|
|
|
+ nonEmptyClosestAncestor: [
|
|
|
+ query('path').isString(),
|
|
|
+ ],
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -939,5 +942,21 @@ module.exports = (crowi) => {
|
|
|
|
|
|
router.put('/:pageId/unpublish', unpublishPageHandlersFactory(crowi));
|
|
|
|
|
|
+ router.get(
|
|
|
+ '/non-empty-closest-ancestor', accessTokenParser, loginRequiredStrictly, validator.nonEmptyClosestAncestor, apiV3FormValidator, async(req, res) => {
|
|
|
+ const { path } = req.query;
|
|
|
+ console.log('ここ', path);
|
|
|
+
|
|
|
+ try {
|
|
|
+ const nonEmptyClosestAncestor = await Page.findNonEmptyClosestAncestor(path);
|
|
|
+ return res.apiv3({ nonEmptyClosestAncestor });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error('Failed to get non-empty closest ancestor', err);
|
|
|
+ return res.apiv3Err(err, 500);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
return router;
|
|
|
};
|