flotilla.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const stack = require("secret-stack");
  2. const shuffle = require("lodash.shuffle");
  3. const debug = require("debug")("oasis");
  4. const ssbConfig = require("ssb-config");
  5. const plugins = [
  6. // Authentication often hooked for authentication.
  7. require("ssb-master"),
  8. // Methods often used during init().
  9. require("ssb-db"),
  10. // Method `replicate()` often hooked for improvements.
  11. require("ssb-replicate"),
  12. // Required by ssb-about, ssb-tangle, etc.
  13. require("ssb-backlinks"),
  14. // Required by ssb-room
  15. require("ssb-conn"),
  16. shuffle([
  17. require("ssb-about"),
  18. require("ssb-blobs"),
  19. require("ssb-ebt"),
  20. require("ssb-friends"),
  21. require("ssb-invite"),
  22. require("ssb-lan"),
  23. require("ssb-logging"),
  24. require("ssb-meme"),
  25. require("ssb-no-auth"),
  26. require("ssb-onion"),
  27. require("ssb-ooo"),
  28. require("ssb-plugins"),
  29. require("ssb-private1"),
  30. require("ssb-query"),
  31. require("ssb-room/tunnel/client"),
  32. require("ssb-search"),
  33. require("ssb-tangle"),
  34. require("ssb-unix-socket"),
  35. require("ssb-ws"),
  36. ]),
  37. ];
  38. module.exports = (config) => {
  39. const server = stack();
  40. // TODO: Move this out of the main function.
  41. const walk = (input) => {
  42. if (Array.isArray(input)) {
  43. input.forEach(walk);
  44. } else {
  45. debug(input.name || "???");
  46. server.use(input);
  47. }
  48. };
  49. walk(plugins);
  50. return server({ ...ssbConfig, ...config });
  51. };