Default interfaces

61 views
Skip to first unread message

Felix Böhm

unread,
Jun 30, 2012, 7:50:40 AM6/30/12
to nod...@googlegroups.com
Hello,

after reading the Database API thread, I was wondering if there was any interest in building a set of default interfaces for node packages. The most compelling advantages:
  • Libraries are interchangeable: You can use a file-based database while developing (eg. SQLite) and switch to another solution (with more space, better performance etc.) by changing a single require statement.
  • Libraries only need to implement a subset of functionality: Escaping SQL queries is a common task for SQL libraries. This could be done by the interface package, so that any implementing package only needs to provide a function for running raw SQL statements (with a well-known name). When the database has a more efficient way of performing a task, the library can simply overwrite the provided functions.
This is not limited to databases: Another cool area would be file-access. A single interface providing a couple of asynchronous methods could be used to not only access the local file-system, but also FTP & WebDAV servers, Dropbox, iCloud & GDrive accounts and even Bittorrent files.

Someone implementing a module for syncing files could rely on that interface and allow users to simply throw in two instances of the interface and do it's job without caring about any underlying architecture. The interface would abstract eg. watching for changes.

Of course, the library can add special behavior for more efficient transfers (eg. between FTP servers using FXP), but that's only optional.

I imagine interfaces to be similar to ES6's proxies: Functions that aren't provided directly are provided using the other functions, as long as that's possible. Besides, they can use util.inherits (or, for CS users, the extends keyword), so that they can be implemented by adding a dependency and inheriting from it.

Of course, this concept needs to be promoted and I'm definitely not the right guy for that task (living in Germany, using node only for fun, never attended a conference etc.), but I would love to work on some of the default interfaces (especially the two mentioned above).

Any thoughts?

Tim Caswell

unread,
Jul 3, 2012, 5:16:23 PM7/3/12
to nod...@googlegroups.com
I am working on such a file system interface.  See it at http://github.com/c9/vfs.  We use it internally in the new cloud9 version.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply all
Reply to author
Forward
0 new messages