Socket
Socket
Sign inDemoInstall

flutterwave-events

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    flutterwave-events

A tiny module to help you handle flutterwave api events automatically


Version published
Weekly downloads
30
decreased by-3.23%
Maintainers
1
Install size
10.2 kB
Created
Weekly downloads
 

Readme

Source

Flutterwave Events

David npm bundle size NPM

Express Middleware that helps you to listen to webhook events from Flutterwave easily, without writing much codes

This module helps you listen to event from Flutterwave webhook securely while emitting it as a NodeJS event which you can listen to easily at any point in your application. It decouples your request handler by emitting the webhook event and returning a response immediately to the caller, so a long-running action won't let the response (which Flutterwave uses to acknowledge your receipt) timeout.

So, Instead of modifying your service that handles the webhook event from your controller, you can just listen to any particular events, and your callback will take care of the rest.

Installing

Install via npm

npm install flutterwave-events

Example

This examples shows how you will use it typically in your express app. It doesn't not show you

require('dotenv/config');
const express = require('express');
const FlutterwaveEvents = require('flutterwave-events');

const flutterwaveEvents = new FlutterwaveEvents(process.env.PAYSTACK_SECRET_KEY);

const app = express();
app.use(express.json());

app.post('/webhook', log, flutterwaveEvents.webhook());

flutterwaveEvents.on('charge.success', (data) => {
  console.log(data);
});
// user.on('body', (x) => console.log(`Yay ${typeof x}`));
app.listen(3000, () => console.log('App started on port 3000'));

{
   "status": "fail",
   "message": "Invalid JSON: The server is unable to process your request as it is badly malformed!
}


const JSONSyntaxErr =  require('json-syntax-error')
...
const app = express();
...
app.use(express.json());
app.use(JSONSyntaxErr()); // That's all, really!

...

You can also pass in your custom response. It can be JSON, HTML, text or any format allowed by express .send()

app.use(JSONSyntaxErr({ error: 'Why are you sending a bad json?' })); // Torture their conscience!

or

app.use(JSONSyntaxErr('<p>Really? A bad JSON? Really?</p>')); // Wasn't hard, was it?!

Tests

npm test

Keywords

FAQs

Last updated on 09 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc