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.

71 lines
2.2 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. contentLicense: WIKI.config.contentLicense,
  17. logoUrl: WIKI.config.logoUrl,
  18. ...WIKI.config.seo,
  19. ...WIKI.config.features,
  20. ...WIKI.config.security
  21. }
  22. }
  23. },
  24. SiteMutation: {
  25. async updateConfig(obj, args, context) {
  26. try {
  27. WIKI.config.host = args.host
  28. WIKI.config.title = args.title
  29. WIKI.config.company = args.company
  30. WIKI.config.contentLicense = args.contentLicense
  31. WIKI.config.seo = {
  32. description: args.description,
  33. robots: args.robots,
  34. analyticsService: args.analyticsService,
  35. analyticsId: args.analyticsId
  36. }
  37. WIKI.config.logoUrl = args.logoUrl
  38. WIKI.config.features = {
  39. featurePageRatings: args.featurePageRatings,
  40. featurePageComments: args.featurePageComments,
  41. featurePersonalWikis: args.featurePersonalWikis
  42. }
  43. WIKI.config.security = {
  44. securityIframe: args.securityIframe,
  45. securityReferrerPolicy: args.securityReferrerPolicy,
  46. securityTrustProxy: args.securityTrustProxy,
  47. securitySRI: args.securitySRI,
  48. securityHSTS: args.securityHSTS,
  49. securityHSTSDuration: args.securityHSTSDuration,
  50. securityCSP: args.securityCSP,
  51. securityCSPDirectives: args.securityCSPDirectives
  52. }
  53. await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'contentLicense', 'seo', 'logoUrl', 'features', 'security'])
  54. if (WIKI.config.security.securityTrustProxy) {
  55. WIKI.app.enable('trust proxy')
  56. } else {
  57. WIKI.app.disable('trust proxy')
  58. }
  59. return {
  60. responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
  61. }
  62. } catch (err) {
  63. return graphHelper.generateError(err)
  64. }
  65. }
  66. }
  67. }