Skip to content

Library updates #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Library updates #57

wants to merge 23 commits into from

Conversation

tu-ru
Copy link

@tu-ru tu-ru commented Mar 5, 2025

Refactored for Better Framework Compatibility

This update makes the library easier to integrate with modern JavaScript frameworks. It works well in Vite + React + TypeScript (simulation mode), with more tests planned for other frameworks.

Key Updates

  • Breaking Changes: The library remains modular, but CommonJS users must set type="module" in package.json.
  • Optional Callbacks: Developers can now use callback handlers (optional) by passing an Express instance to handle callbacks on supported APIs.
  • More Endpoints: Now supports 12 API endpoints, but some require external configuration for production.
  • Type Definitions: Clear guidelines for passing data to each API.
  • Improved Testing: Uses Mocha with ES6 modules (BDD approach). Current tests serve as usage examples.
  • Better Code Structure: More organized for easier maintenance.
  • README + JSDocs update: The README.md is up-to-date with the current updates. The library now contains local JSDocs documentation, adding accessibility

Next Steps

  • Test the library on more frameworks.
  • Verify functionality in production environments.

This update makes the library simpler and more flexible. Open to feedback!

tu-ru added 23 commits November 3, 2024 09:02
Updated the mpesa-node library to use latest npm packages. Added new API's from daraja 2.0, new tests with an optional result body, types for typescript users, better babel configuration for seamless es6 mocha tests, and better folder structure
Reverting back to the original structure, so as to create an npm standard library branch
Implemented a 4 sec timeout code to exit the testing stage effectively, as I was facing issues with closing ngrok and app server properly. I have also fixed the transaction status API route
Cleaning up unnecessary files and re-structuring the folders, for a more npm like standard setup
created a .env.example file for users to rely on when fetching their keys from daraja 2.0
Following proper naming conventions, I came up with
…th. All this to push on proper library management
…tically, without having to explicitly passing them as function parameters, maintaining credential security, and simplifying the API parameter section. The mechanism automatically sets baseURL based on the environment, and chooses which .env to use, depending on how the user uses the library
…ment, to handle errors in a more user-friendly way. I have also updated the core api files to have advanced error logging
 The lib has capability to automatically determine the certificate based on the provided .env file
…ocs and root README.md for better readability. This commit also houses better tests, with optional callback handling. I've also performed minor enhancements, just to streamline the library and make it better for everyone
…'s explicitly URL. This helps avoid confusions in realtime usage
…ave omitted, taxRemittance and c2bRegister because of the extra external configurations, required for them to perform properly. I have combined M-pesa query and M-pesa express into one test file, since the CheckoutRequestID released by M-pesa express, is expected to be passed down to M-pesa query. I have also reformatted the whole code base and updated the docs
…rd addition. This will ensure that developers searching for different variations of M-Pesa integrations, SDKs, and modules will find your library more easily
…transaction. Added multiline comments in each test file, describing what the test does
@tu-ru tu-ru closed this Mar 24, 2025
@tu-ru tu-ru deleted the npm-standard-lib branch March 24, 2025 07:59
@tu-ru tu-ru restored the npm-standard-lib branch March 27, 2025 06:59
@tu-ru tu-ru reopened this Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant