admin-home.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { configManager } from '~/server/service/config-manager';
  2. import { getGrowiVersion } from '~/utils/growi-version';
  3. const express = require('express');
  4. const router = express.Router();
  5. /**
  6. * @swagger
  7. *
  8. * components:
  9. * schemas:
  10. * SystemInformationParams:
  11. * type: object
  12. * properties:
  13. * growiVersion:
  14. * type: string
  15. * description: GROWI version or '-'
  16. * example: 7.1.0-RC.0
  17. * nodeVersion:
  18. * type: string
  19. * description: node version or '-'
  20. * example: 20.2.0
  21. * npmVersion:
  22. * type: string
  23. * description: npm version or '-'
  24. * example: 9.6.6
  25. * pnpmVersion:
  26. * type: string
  27. * description: pnpm version or '-'
  28. * example: 9.12.3
  29. * envVars:
  30. * type: object
  31. * description: environment variables
  32. * additionalProperties:
  33. * type: string
  34. * example:
  35. * "FILE_UPLOAD": "mongodb"
  36. * "APP_SITE_URL": "http://localhost:3000"
  37. * "ELASTICSEARCH_URI": "http://elasticsearch:9200/growi"
  38. * "ELASTICSEARCH_REQUEST_TIMEOUT": 15000
  39. * "ELASTICSEARCH_REJECT_UNAUTHORIZED": true
  40. * "OGP_URI": "http://ogp:8088"
  41. * "QUESTIONNAIRE_SERVER_ORIGIN": "http://host.docker.internal:3003"
  42. * isV5Compatible:
  43. * type: boolean
  44. * description: This value is true if this GROWI is compatible v5.
  45. * example: true
  46. * isMaintenanceMode:
  47. * type: boolean
  48. * description: This value is true if this site is maintenance mode.
  49. * example: false
  50. * InstalledPluginsParams:
  51. * type: object
  52. * properties:
  53. * installedPlugins:
  54. * type: object
  55. * description: installed plugins
  56. */
  57. /** @param {import('~/server/crowi').default} crowi Crowi instance */
  58. module.exports = (crowi) => {
  59. const loginRequiredStrictly = require('../../middlewares/login-required')(crowi);
  60. const adminRequired = require('../../middlewares/admin-required')(crowi);
  61. /**
  62. * @swagger
  63. *
  64. * /admin-home/:
  65. * get:
  66. * tags: [AdminHome]
  67. * summary: /admin-home
  68. * security:
  69. * - cookieAuth: []
  70. * description: Get adminHome parameters
  71. * responses:
  72. * 200:
  73. * description: params of adminHome
  74. * content:
  75. * application/json:
  76. * schema:
  77. * properties:
  78. * adminHomeParams:
  79. * $ref: "#/components/schemas/SystemInformationParams"
  80. */
  81. router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
  82. const { getRuntimeVersions } = await import('~/server/util/runtime-versions');
  83. const runtimeVersions = await getRuntimeVersions();
  84. const adminHomeParams = {
  85. growiVersion: getGrowiVersion(),
  86. nodeVersion: runtimeVersions.node ?? '-',
  87. npmVersion: runtimeVersions.npm ?? '-',
  88. pnpmVersion: runtimeVersions.pnpm ?? '-',
  89. envVars: configManager.getManagedEnvVars(),
  90. isV5Compatible: configManager.getConfig('app:isV5Compatible'),
  91. isMaintenanceMode: configManager.getConfig('app:isMaintenanceMode'),
  92. };
  93. return res.apiv3({ adminHomeParams });
  94. });
  95. return router;
  96. };