account.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const moduleManager = require("../../../index");
  2. const accountModule = moduleManager.modules["account"];
  3. const mongoModule = moduleManager.modules["mongo"];
  4. const utilModule = moduleManager.modules["util"];
  5. module.exports = {
  6. "getAll": async cb => {
  7. accountModule.getAll().then(accounts => {
  8. cb({
  9. status: "success",
  10. accounts
  11. });
  12. }).catch(err => {
  13. cb({
  14. status: "failure"
  15. });
  16. });
  17. },
  18. "getById": (cb, accountId) => {
  19. accountModule.getById(accountId).then(account => {
  20. cb({
  21. status: "success",
  22. account
  23. });
  24. }).catch(err => {
  25. cb({
  26. status: "failure"
  27. });
  28. });
  29. },
  30. "add": (cb, account) => {
  31. accountModule.add(account).then(() => {
  32. console.log("Added account!");
  33. cb({
  34. status: "success"
  35. });
  36. }).catch(err => {
  37. cb({
  38. status: "failure"
  39. });
  40. });
  41. },
  42. "editById": (cb, accountId, account) => {
  43. accountModule.editById(accountId, account).then(() => {
  44. console.log("Edited account!");
  45. cb({
  46. status: "success"
  47. });
  48. }).catch(err => {
  49. cb({
  50. status: "failure"
  51. });
  52. });
  53. }
  54. }