convertSchema.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const moduleManager = require("../../../index");
  2. const mongoModule = moduleManager.modules["mongo"];
  3. const convertSchemaModule = moduleManager.modules["convertSchema"];
  4. module.exports = {
  5. "getForVersion": (cb, version) => {
  6. convertSchemaModule.getForVersion(version).then(schema => {
  7. cb({
  8. status: "success",
  9. schema
  10. });
  11. }).catch(err => {
  12. cb({
  13. status: "failure"
  14. });
  15. });
  16. },
  17. "getById": (cb, schemaId) => {
  18. convertSchemaModule.getById(schemaId).then(schema => {
  19. cb({
  20. status: "success",
  21. schema
  22. });
  23. }).catch(err => {
  24. cb({
  25. status: "failure"
  26. });
  27. });
  28. },
  29. "removeById": (cb, schemaId) => {
  30. convertSchemaModule.removeById(schemaId).then(() => {
  31. cb({
  32. status: "success"
  33. });
  34. }).catch(err => {
  35. cb({
  36. status: "failure"
  37. });
  38. });
  39. },
  40. "getAll": (cb) => {
  41. convertSchemaModule.getAll().then(schemas => {
  42. cb({
  43. status: "success",
  44. schemas
  45. });
  46. }).catch(err => {
  47. cb({
  48. status: "failure"
  49. });
  50. });
  51. },
  52. "import": (cb, name) => {
  53. convertSchemaModule.import(name).then(() => {
  54. cb({
  55. status: "success"
  56. });
  57. }).catch(err => {
  58. cb({
  59. status: "failure",
  60. error: err.message
  61. });
  62. });
  63. }
  64. }