The frontend/UI server, written in JS using the MarkoJS library
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.

49 lines
1.0 KiB

6 years ago
6 years ago
6 years ago
  1. const fs = require("fs")
  2. const config = {
  3. graphqlEndpoint: "http://127.0.0.1:17000/graphql",
  4. playgroundEndpoint: "http://127.0.0.1:17000/playground",
  5. port: 8080,
  6. root: "http://localhost:8080",
  7. trustedProxy: null,
  8. auth0: {
  9. secret: "INVALID_SECRET",
  10. clientId: "",
  11. domain: "aiterp.eu.auth0.com",
  12. },
  13. session: {
  14. secret: "",
  15. secure: false,
  16. },
  17. redis: {
  18. host: "127.0.0.1",
  19. port: 6379,
  20. },
  21. backend: {
  22. kid: "",
  23. secret: "",
  24. }
  25. }
  26. if (typeof(window) !== "undefined") {
  27. config.graphqlEndpoint = "/graphql"
  28. delete config.port
  29. delete config.root
  30. delete config.auth0
  31. delete config.session
  32. delete config.redis
  33. delete config.backend
  34. } else {
  35. try {
  36. const data = fs.readFileSync("/etc/aiterp/rpdata-frontend.json", "utf8")
  37. const parsed = JSON.parse(data)
  38. if (typeof(parsed) == "object" && !Array.isArray(parsed)) {
  39. Object.assign(config, parsed)
  40. }
  41. } catch(err) {
  42. console.error("Failed to load configuration: " + err.message || err.stack || err)
  43. }
  44. }
  45. module.exports = config