diff --git a/lib/db.js b/lib/db.js index a1fe32c..5f3b4a4 100644 --- a/lib/db.js +++ b/lib/db.js @@ -1,13 +1,29 @@ const Tapable = require('tapable') + +// {'endpoint': [fn, fn]} class DB extends Tapable { - constructor() { - // TODO - } + constructor(options) { + // TODO + super(); + this.options = options || {}; + } - request() { - // TODO - } + request (params = {}) { + // TODO + const options = this.applyPluginsWaterfall('options', this.options); + + return this.applyPluginsBailResult('endpoint', Object.assign(params, options)) + .then(res => { + if(this.applyPluginsBailResult('judge', res)){ + return Promise.reject(res); + } + return Promise.resolve(res); + }) + .catch(err => { + return Promise.reject(err); + }) + } } module.exports = DB \ No newline at end of file