mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-18 15:18:04 +00:00
* 'feature/process-fork-messaging' of git://github.com/jsbin/jsbin: (54 commits) move zmq to optional deps dont send options to zmq pass type to jobsworth pass access token, not user only start dropbox if we initialize it dont pass app to dropbox initialize Update flash message text Add link to dropbox button Stringify options before sending put /auth/dropbox behind a feature flag Add dropbox feature Stringify object before sending add zmq as dependancy revert removal of template update dropbox for zmq/jobsworth Add commented out debugger move callback url to config access_token => accessToken Remove parent.js Add flash message to confirm dropbox linking ... Conflicts: lib/addons/memcached/index.js lib/features.js package.json
78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
var metrics = require('./metrics');
|
|
|
|
function Store(options) {
|
|
var Adapter = require('./db/' + options.adapter);
|
|
this.adapter = new Adapter(options[options.adapter]);
|
|
check(this.adapter, methods);
|
|
}
|
|
|
|
var check = function (adapter, methods) {
|
|
methods.forEach(function (method) {
|
|
if (!adapter[method]) throw new Error("DB adapter missing method: " + method);
|
|
});
|
|
};
|
|
|
|
// Methods that should be supported by adaptors.
|
|
var methods = [
|
|
'connect',
|
|
'disconnect',
|
|
'setBin',
|
|
'setBinOwner',
|
|
'setBinPanel',
|
|
'getBin',
|
|
'getLatestBin',
|
|
'getLatestBinForUser',
|
|
'getBinsByUser',
|
|
'generateBinId',
|
|
'archiveBin',
|
|
'getUser',
|
|
'getUserByEmail',
|
|
'getUserByApiKey',
|
|
'setUser',
|
|
'touchLogin',
|
|
'touchOwners',
|
|
'updateOwners',
|
|
'updateUserEmail',
|
|
'updateUserGithubData',
|
|
'updateUserDropboxData',
|
|
'updateUserKey',
|
|
'upgradeUserKey',
|
|
'getUserByForgotToken',
|
|
'setForgotToken',
|
|
'expireForgotToken',
|
|
'expireForgotTokenByUser',
|
|
'reportBin',
|
|
'getAllOwners',
|
|
'updateUserSettings',
|
|
'getOwnersBlock',
|
|
'isOwnerOf',
|
|
'getUserBinCount',
|
|
'populateOwners',
|
|
'getOne',
|
|
'setProAccount',
|
|
'setCustomer',
|
|
'setCustomerActive',
|
|
'getCustomerByStripeId',
|
|
'getCustomerByUser',
|
|
'getBinMetadata',
|
|
'setBinVisibility',
|
|
'updateBinData',
|
|
'updateOwnersData',
|
|
'saveBookmark',
|
|
'getBookmark',
|
|
];
|
|
|
|
// Proxy the methods through the store.
|
|
methods.forEach(function (method) {
|
|
Store.prototype[method] = function () {
|
|
metrics.increment('db.method');
|
|
metrics.increment('db.method.' + method);
|
|
this.adapter[method].apply(this.adapter, arguments);
|
|
};
|
|
});
|
|
|
|
module.exports = function createStore(options) {
|
|
return new Store(options);
|
|
};
|
|
module.exports.Store = Store;
|