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.

48 lines
1.0 KiB

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