Initial commit
commit
bc9b5ec289
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
yarn.lock
|
@ -0,0 +1,23 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const Promise = require("bluebird");
|
||||||
|
const mapObj = require("map-obj");
|
||||||
|
const databaseError = require("database-error");
|
||||||
|
|
||||||
|
function wrapMethod(value) {
|
||||||
|
if (typeof value === "function") {
|
||||||
|
return function wrappedDatabaseMethod(...args) {
|
||||||
|
return Promise.try(() => {
|
||||||
|
return value.call(this, ...args);
|
||||||
|
}).catch(databaseError.rethrow);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function createDatabaseModule(methods) {
|
||||||
|
return mapObj(methods, (key, value) => {
|
||||||
|
return [key, wrapMethod(value)];
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "node-database-module",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": "http://git.cryto.net/joepie91/node-database-module.git",
|
||||||
|
"author": "Sven Slootweg <admin@cryto.net>",
|
||||||
|
"license": "WTFPL OR CC0-1.0",
|
||||||
|
"dependencies": {
|
||||||
|
"bluebird": "^3.5.4",
|
||||||
|
"database-error": "^2.0.1",
|
||||||
|
"map-obj": "^3.1.0"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue