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.

47 lines
980 B

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