jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.07k stars 218 forks source link

Take a modular approach to backends #42

Closed lavelle closed 11 years ago

lavelle commented 11 years ago

I opted to make my Dropbox backend a separate repo, because it seems like it should be an optional plug-in rather than core functionality. The four existing filesystems are universal enough to be part of the core, but I propose that any future ones be modular plugins.

We could create a method for registering a new backend on the BrowserFS namespace, like _.mixin, so validation can be performed.

Others could then add their own backends without needing to send PRs to this repo.

We could have a wiki page with a list of all backends.

I can then add other cloud storage providers (Box, Google Drive, etc.) this way.

Backends can list this repo as a dependency in their bower.json.

This would also suggest separating the test suite into its own repo. I'm trying to hook the Dropbox backend up to the Karma test suite but because the tests are in this repo, I'm just doing a messy ../dropbox-fs/dropbox.js hack in karma.conf.js.

Since the external API is always the same, only the implementation differs between backends, the one test suite should be enough for all plugins (plugins can obviously have their own test suites as well for testing internal behaviour).

jvilk commented 11 years ago

We're already modular! You don't need to register with BrowserFS. As long as you satisfy the BrowserFS backend API and inherit from its core classes, you can pass your backend in as a root filesystem or mount it into the MountableFileSystem.

jvilk commented 11 years ago

As for validation, you'll get that for free when we move to TypeScript.

I agree that we probably need a better testing option for people making external modules.

lavelle commented 11 years ago

Yeah sure, I realise the design is modular, I was more saying "make modular backends the official policy of this project", rather than "make it possible". Sounds like having a registration method is overkill then, I'll just add things to the namespace.

jvilk commented 11 years ago

Yeah, I agree that we should be modular by default -- we should allow people to minimize deployment size by deploying only the backends they care about. I just didn't put too much work into it, as the payoff was minimal compared with getting everything working more-or-less correctly (worse is better).

jvilk commented 11 years ago

This is subsumed by #46.