|
|
@@ -1,9 +1,12 @@
|
|
|
+import path from 'path';
|
|
|
+
|
|
|
import { GrowiPluginType } from '@growi/core';
|
|
|
import { TemplateSummary } from '@growi/pluginkit/dist/v4';
|
|
|
import { scanAllTemplates, getMarkdown } from '@growi/pluginkit/dist/v4/server';
|
|
|
import express from 'express';
|
|
|
import { param, query } from 'express-validator';
|
|
|
|
|
|
+import { PLUGIN_STORING_PATH } from '~/features/growi-plugin/server/consts';
|
|
|
import { GrowiPlugin } from '~/features/growi-plugin/server/models';
|
|
|
import { apiV3FormValidator } from '~/server/middlewares/apiv3-form-validator';
|
|
|
import { ApiV3Response } from '~/server/routes/apiv3/interfaces/apiv3-response';
|
|
|
@@ -60,17 +63,32 @@ module.exports = (crowi) => {
|
|
|
} = req.params;
|
|
|
|
|
|
const presetTemplatesRoot = resolveFromRoot('../../node_modules/@growi/preset-templates');
|
|
|
- const markdown = await getMarkdown(presetTemplatesRoot, templateId, locale);
|
|
|
|
|
|
- return res.apiv3({ markdown });
|
|
|
+ try {
|
|
|
+ const markdown = await getMarkdown(presetTemplatesRoot, templateId, locale);
|
|
|
+ return res.apiv3({ markdown });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ res.apiv3Err(err);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
- router.get('/plugin-templates/:pluginId/:templateId/:locale', loginRequiredStrictly, validator.get, apiV3FormValidator, async(req, res: ApiV3Response) => {
|
|
|
+ router.get('/plugin-templates/:organizationId/:reposId/:templateId/:locale', loginRequiredStrictly, validator.get, apiV3FormValidator, async(
|
|
|
+ req, res: ApiV3Response,
|
|
|
+ ) => {
|
|
|
const {
|
|
|
- pluginId, templateId, locale,
|
|
|
+ organizationId, reposId, templateId, locale,
|
|
|
} = req.params;
|
|
|
|
|
|
- return res.apiv3({});
|
|
|
+ const pluginRoot = path.join(PLUGIN_STORING_PATH, `${organizationId}/${reposId}`);
|
|
|
+
|
|
|
+ try {
|
|
|
+ const markdown = await getMarkdown(pluginRoot, templateId, locale);
|
|
|
+ return res.apiv3({ markdown });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ res.apiv3Err(err);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
return router;
|