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.

69 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. logoUrl: WIKI.config.logoUrl,
  17. ...WIKI.config.seo,
  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.logoUrl = args.logoUrl
  36. WIKI.config.features = {
  37. featurePageRatings: args.featurePageRatings,
  38. featurePageComments: args.featurePageComments,
  39. featurePersonalWikis: args.featurePersonalWikis
  40. }
  41. WIKI.config.security = {
  42. securityIframe: args.securityIframe,
  43. securityReferrerPolicy: args.securityReferrerPolicy,
  44. securityTrustProxy: args.securityTrustProxy,
  45. securitySRI: args.securitySRI,
  46. securityHSTS: args.securityHSTS,
  47. securityHSTSDuration: args.securityHSTSDuration,
  48. securityCSP: args.securityCSP,
  49. securityCSPDirectives: args.securityCSPDirectives
  50. }
  51. await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logoUrl', 'features', 'security'])
  52. if (WIKI.config.security.securityTrustProxy) {
  53. WIKI.app.enable('trust proxy')
  54. } else {
  55. WIKI.app.disable('trust proxy')
  56. }
  57. return {
  58. responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
  59. }
  60. } catch (err) {
  61. return graphHelper.generateError(err)
  62. }
  63. }
  64. }
  65. }