api.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. const CoreClass = require("../core.js");
  2. class APIModule extends CoreClass {
  3. constructor() {
  4. super("api");
  5. }
  6. initialize() {
  7. return new Promise((resolve, reject) => {
  8. const app = this.moduleManager.modules["app"];
  9. const actions = require("./actions");
  10. app.runJob("GET_APP", {})
  11. .then((response) => {
  12. response.app.get("/", (req, res) => {
  13. res.json({
  14. status: "success",
  15. message: "Coming Soon",
  16. });
  17. });
  18. // Object.keys(actions).forEach(namespace => {
  19. // Object.keys(actions[namespace]).forEach(action => {
  20. // let name = `/${namespace}/${action}`;
  21. // response.app.get(name, (req, res) => {
  22. // actions[namespace][action](null, result => {
  23. // if (typeof cb === "function")
  24. // return res.json(result);
  25. // });
  26. // });
  27. // });
  28. // });
  29. resolve();
  30. })
  31. .catch((err) => {
  32. reject(err);
  33. });
  34. });
  35. }
  36. }
  37. module.exports = new APIModule();