You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

  1. const graphHelper = require('../../helpers/graph')
  2. /* global WIKI */
  3. module.exports = {
  4. Query: {
  5. async site() { return {} }
  6. },
  7. Mutation: {
  8. async site() { return {} }
  9. },
  10. SiteQuery: {
  11. async config(obj, args, context, info) {
  12. return {
  13. host: WIKI.config.host,
  14. title: WIKI.config.title,
  15. company: WIKI.config.company,
  16. ...WIKI.config.seo,
  17. ...WIKI.config.logo,
  18. ...WIKI.config.features,
  19. ...WIKI.config.security
  20. }
  21. }
  22. },
  23. SiteMutation: {
  24. async updateConfig(obj, args, context) {
  25. try {
  26. WIKI.config.host = args.host
  27. WIKI.config.title = args.title
  28. WIKI.config.company = args.company
  29. WIKI.config.seo = {
  30. description: args.description,
  31. robots: args.robots,
  32. analyticsService: args.analyticsService,
  33. analyticsId: args.analyticsId
  34. }
  35. WIKI.config.logo = {
  36. hasLogo: args.hasLogo,
  37. logoIsSquare: args.logoIsSquare
  38. }
  39. WIKI.config.features = {
  40. featurePageRatings: args.featurePageRatings,
  41. featurePageComments: args.featurePageComments,
  42. featurePersonalWikis: args.featurePersonalWikis
  43. }
  44. WIKI.config.security = {
  45. securityIframe: args.securityIframe,
  46. securityReferrerPolicy: args.securityReferrerPolicy,
  47. securityTrustProxy: args.securityTrustProxy,
  48. securitySRI: args.securitySRI,
  49. securityHSTS: args.securityHSTS,
  50. securityHSTSDuration: args.securityHSTSDuration,
  51. securityCSP: args.securityCSP,
  52. securityCSPDirectives: args.securityCSPDirectives
  53. }
  54. await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logo', 'features', 'security'])
  55. if (WIKI.config.security.securityTrustProxy) {
  56. WIKI.app.enable('trust proxy')
  57. } else {
  58. WIKI.app.disable('trust proxy')
  59. }
  60. return {
  61. responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
  62. }
  63. } catch (err) {
  64. return graphHelper.generateError(err)
  65. }
  66. }
  67. }
  68. }