mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-18 15:18:04 +00:00
34 lines
704 B
JavaScript
34 lines
704 B
JavaScript
function Store(options) {
|
|
var Adapter = require('./db/' + options.adapter);
|
|
this.adapter = new Adapter(options[options.adapter]);
|
|
}
|
|
|
|
// Methods that should be supported by adaptors.
|
|
var methods = [
|
|
'connect',
|
|
'disconnect',
|
|
'setBin',
|
|
'setBinUser',
|
|
'setBinPanel',
|
|
'getBin',
|
|
'getLatestBin',
|
|
'getBinsByUser',
|
|
'generateBinId',
|
|
'getUser',
|
|
'setUser',
|
|
'touchLogin',
|
|
'updateUserKey'
|
|
];
|
|
|
|
// Proxy the methods through the store.
|
|
methods.forEach(function (method) {
|
|
Store.prototype[method] = function () {
|
|
this.adapter[method].apply(this.adapter, arguments);
|
|
};
|
|
});
|
|
|
|
module.exports = function createStore(options) {
|
|
return new Store(options);
|
|
};
|
|
module.exports.Store = Store;
|