export.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const path = require('path');
  2. module.exports = (dbconfig) => {
  3. var RepositorySystem = require('../systems/RepositorySystem').setDB(dbconfig);
  4. var RoutingSystem = require('../systems/RoutingSystem');
  5. var AdminSystem = require('../systems/AdminSystem');
  6. var UserSystem = require('../systems/UserSystem');
  7. var ModuleSystem = require('../systems/ModuleSystem');
  8. var Filters = require('../modules/Filters/FilterService');
  9. var Mods = require('../modules/index.js');
  10. function loadApp(app) {
  11. ModuleSystem.loadModules(path.resolve(__dirname, "../modules"));
  12. ModuleSystem.run();
  13. app.use(UserSystem.Middleware);
  14. app.use(UserSystem.Middleware);
  15. app.use(Filters.Middleware);
  16. app.use(RoutingSystem.router);
  17. }
  18. function main(app) {
  19. ModuleSystem.loadModule(Mods.Users)
  20. ModuleSystem.loadModule(Mods.Account)
  21. ModuleSystem.loadModule(Mods.Globals)
  22. ModuleSystem.loadModule(Mods.Files)
  23. ModuleSystem.loadModule(Mods.Filters)
  24. ModuleSystem.run();
  25. app.use(UserSystem.Middleware);
  26. app.use(UserSystem.Middleware);
  27. app.use(Filters.Middleware);
  28. app.use(RoutingSystem.router);
  29. }
  30. const Systems = {
  31. RoutingSystem,
  32. RepositorySystem,
  33. AdminSystem,
  34. UserSystem,
  35. ModuleSystem,
  36. Filters
  37. }
  38. return {
  39. load: (app) => {
  40. loadApp(app);
  41. return Systems;
  42. },
  43. minimal: (app) => {
  44. main(app);
  45. return Systems;
  46. },
  47. Systems,
  48. Modules: Mods
  49. }
  50. };