From 4b541f7f8235066e029aa3e82c2f1d78fdba715c Mon Sep 17 00:00:00 2001 From: kent Date: Wed, 25 Feb 2026 10:29:45 +0000 Subject: [PATCH] fix: cleanup unused deps, fix bugs, restore commented-out features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove unused production dependencies (axios, q, bluebird, chai-as-promised-also-chain); move eslint-config-prettier to devDependencies. Removes axios entirely — the codebase already uses native fetch. Fixes #168 (Cloudflare Workers compatibility). 2. Fix repository URLs in package.json — pointed to the old Flutterwave-node-v3 repo instead of the current Node-v3. 3. Bump node-forge from pinned 1.3.2 to ^1.3.3 (security fix). 4. Remove committed .DS_Store and add it to .gitignore. 5. Restore CustomRequest feature (fixes #117) — uncommented and modernized to use async/await with the existing _rave.request() pattern instead of the old q/morx dependencies. 6. Restore voucher charge service — was entirely commented out, causing Charge.voucher() to throw TypeError. Rewritten using the modern async/await pattern matching other charge services. 7. Fix operator precedence bug in rave.base.js: - `'POST' || 'PUT'` always evaluates to 'POST' (dead code) - `requestMethod == 'POST' || 'PUT'` always truthy ('PUT' is truthy) - Fixed to proper `requestMethod === 'POST' || requestMethod === 'PUT'` - Also: `datakey == 'body' ? true : false` simplified to `datakey === 'body'` - Removed unused `var q = require('q')` import 8. Fix broken anchor link in documentation/transactions.md — "Verify transaction with reference" linked to #verify-transaction instead of #verify-transaction-with-reference. --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 3 +- documentation/transactions.md | 2 +- index.js | 4 +- lib/rave.base.js | 7 ++- lib/rave.custom.js | 16 +++---- package.json | 15 +++---- services/charge/rave.voucher.js | 76 ++++++-------------------------- services/rave.custom.request.js | 33 ++++---------- 9 files changed, 42 insertions(+), 114 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 { - -// var validated = morx.validate(data, spec, _rave.MORX_DEFAULT, {throw_error:true}); -// var params = validated.params; - -// return (params); - -// }) -// .then(params => { - -// return _rave.request('v3/charges?type=voucher_payment', params) -// }) -// .then(response => { - -// d.resolve(response.body); - -// }) -// .catch(err => { - -// d.reject(err); - -// }) - -// return d.promise; - -// } -// service.morxspc = spec; -// module.exports = service; +const { validator } = require('../../utils/validator'); +const { chargeSchema } = require('../schema/create'); + +async function service(data, _rave) { + validator(chargeSchema, data); + const { body: response } = await _rave.request( + `v3/charges?type=voucher_payment`, + data, + ); + return response; +} + +module.exports = service; diff --git a/services/rave.custom.request.js b/services/rave.custom.request.js index b11b784..e6306ba 100644 --- a/services/rave.custom.request.js +++ b/services/rave.custom.request.js @@ -1,27 +1,10 @@ -// var morx = require('morx'); +async function service(path, data, _rave) { + if (!path) { + throw new Error('A valid path is required for custom requests'); + } -// var q = require('q'); + const { body: response } = await _rave.request(path, data); + return response; +} -// function newRefund(path, data, _rave) { -// var d = q.defer(); - -// q.fcall(() => { -// path = path || 'NO PATH PASSED, PLEASE PASS A VALID PATH'; - -// if (path == 'NO PATH PASSED, PLEASE PASS A VALID PATH') { -// throw path; -// } - -// return _rave.request(path, data); -// }) -// .then((response) => { -// d.resolve(response); -// }) -// .catch((err) => { -// d.reject(err); -// }); - -// return d.promise; -// } - -// module.exports = newRefund; +module.exports = service;