|
@@ -17,6 +17,9 @@ const validator = {
|
|
|
body('globalLang').isIn(['en-US', 'ja']),
|
|
body('globalLang').isIn(['en-US', 'ja']),
|
|
|
body('fileUpload').isBoolean(),
|
|
body('fileUpload').isBoolean(),
|
|
|
],
|
|
],
|
|
|
|
|
+ siteUrlSetting: [
|
|
|
|
|
+ body('siteUrl').trim(),
|
|
|
|
|
+ ],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@@ -46,6 +49,12 @@ const validator = {
|
|
|
* fileUpload:
|
|
* fileUpload:
|
|
|
* type: boolean
|
|
* type: boolean
|
|
|
* description: enable upload file except image file
|
|
* description: enable upload file except image file
|
|
|
|
|
+ * siteUrl:
|
|
|
|
|
+ * type: String
|
|
|
|
|
+ * description: Site URL. e.g. https://example.com, https://example.com:8080
|
|
|
|
|
+ * envSiteUrl:
|
|
|
|
|
+ * type: String
|
|
|
|
|
+ * description: environment variable 'APP_SITE_URL'
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
module.exports = (crowi) => {
|
|
module.exports = (crowi) => {
|
|
@@ -60,7 +69,7 @@ module.exports = (crowi) => {
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
|
- * /app-settings/app-setting:
|
|
|
|
|
|
|
+ * /app-settings/:
|
|
|
* get:
|
|
* get:
|
|
|
* tags: [AppSettings]
|
|
* tags: [AppSettings]
|
|
|
* description: get app setting params
|
|
* description: get app setting params
|
|
@@ -83,13 +92,21 @@ module.exports = (crowi) => {
|
|
|
* fileUpload:
|
|
* fileUpload:
|
|
|
* type: boolean
|
|
* type: boolean
|
|
|
* description: enable upload file except image file
|
|
* description: enable upload file except image file
|
|
|
|
|
+ * siteUrl:
|
|
|
|
|
+ * type: String
|
|
|
|
|
+ * description: Site URL. e.g. https://example.com, https://example.com:8080
|
|
|
|
|
+ * envSiteUrl:
|
|
|
|
|
+ * type: String
|
|
|
|
|
+ * description: environment variable 'APP_SITE_URL'
|
|
|
*/
|
|
*/
|
|
|
- router.get('/app-setting', accessTokenParser, loginRequired, adminRequired, async(req, res) => {
|
|
|
|
|
|
|
+ router.get('/', accessTokenParser, loginRequired, adminRequired, async(req, res) => {
|
|
|
const appSettingParams = {
|
|
const appSettingParams = {
|
|
|
title: crowi.configManager.getConfig('crowi', 'app:title'),
|
|
title: crowi.configManager.getConfig('crowi', 'app:title'),
|
|
|
confidential: crowi.configManager.getConfig('crowi', 'app:confidential'),
|
|
confidential: crowi.configManager.getConfig('crowi', 'app:confidential'),
|
|
|
globalLang: crowi.configManager.getConfig('crowi', 'app:globalLang'),
|
|
globalLang: crowi.configManager.getConfig('crowi', 'app:globalLang'),
|
|
|
fileUpload: crowi.configManager.getConfig('crowi', 'app:fileUpload'),
|
|
fileUpload: crowi.configManager.getConfig('crowi', 'app:fileUpload'),
|
|
|
|
|
+ siteUrl: crowi.configManager.getConfig('crowi', 'app:siteUrl'),
|
|
|
|
|
+ envSiteUrl: crowi.configManager.getConfigFromEnvVars('crowi', 'app:siteUrl'),
|
|
|
};
|
|
};
|
|
|
return res.apiv3({ appSettingParams });
|
|
return res.apiv3({ appSettingParams });
|
|
|
|
|
|
|
@@ -159,6 +176,54 @@ module.exports = (crowi) => {
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @swagger
|
|
|
|
|
+ *
|
|
|
|
|
+ * /app-settings/site-url-setting:
|
|
|
|
|
+ * put:
|
|
|
|
|
+ * tags: [AppSettings]
|
|
|
|
|
+ * description: Update site url setting
|
|
|
|
|
+ * requestBody:
|
|
|
|
|
+ * required: true
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * type: object
|
|
|
|
|
+ * properties:
|
|
|
|
|
+ * siteUrl:
|
|
|
|
|
+ * type: String
|
|
|
|
|
+ * description: Site URL. e.g. https://example.com, https://example.com:8080
|
|
|
|
|
+ * responses:
|
|
|
|
|
+ * 200:
|
|
|
|
|
+ * description: Succeeded to update site url setting
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * properties:
|
|
|
|
|
+ * status:
|
|
|
|
|
+ * $ref: '#/components/schemas/appSettingParams'
|
|
|
|
|
+ */
|
|
|
|
|
+ router.put('/site-url-setting', loginRequiredStrictly, adminRequired, csrf, validator.siteUrlSetting, ApiV3FormValidator, async(req, res) => {
|
|
|
|
|
+
|
|
|
|
|
+ const requestSiteUrlSettingParams = {
|
|
|
|
|
+ 'app:siteUrl': req.body.siteUrl,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestSiteUrlSettingParams);
|
|
|
|
|
+ const appSettingParams = {
|
|
|
|
|
+ siteUrl: crowi.configManager.getConfig('crowi', 'app:siteUrl'),
|
|
|
|
|
+ };
|
|
|
|
|
+ return res.apiv3({ appSettingParams });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ const msg = 'Error occurred in updating site url setting';
|
|
|
|
|
+ logger.error('Error', err);
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'update-siteUrlSetting-failed'));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
|
|
|
return router;
|
|
return router;
|
|
|
};
|
|
};
|