This project implements and tests a webhook handler for Raven bank transfer notifications. It includes a secure Express endpoint, controller logic, database interactions using Knex.js, and a comprehensive test suite using Jest.
The full Postman documentation can be found here:
👉 View API Docs
.
├── src/
│ ├── app.js # Express app
│ ├── controllers/
│ │ └── transferwebhook.controller.js # Core webhook logic
│ └── models/
│ └── transferwebhook.model.js # DB operations with Knex
│
├── test/
│ ├── webhook-handler.test.js # Controller unit tests
│ ├── webhook-route.test.js # Endpoint integration tests
│ └── setup.js # Test user creation and JWT
│
├── knex.js # Initialized Knex instance
├── .env # Secrets and configs
└── README.md
git clone https://github.com/josiahking/fintechapp-demo.git
cd fintechapp-demo
npm install
Create a .env
file with:
PORT=3000
DATABASE_URL=mysql://user:pass@localhost:3306/dbname
JWT_SECRET=testsecret
RAVEN_WEBHOOK_SECRET=your_webhook_secret
npx knex migrate:latest
npm run dev
Tests are powered by Jest and include:
- Controller logic tests
- Express route integration tests
- Secure webhook validation
- Database inserts verification
Run all tests with:
npm test
Raven sends a secret
field with webhook payloads. Your server compares this to RAVEN_WEBHOOK_SECRET
in .env
for validation.
- Requests without a valid
secret
are rejected with 401 Unauthorized. - Webhook payloads are logged in
webhook_events
table for traceability.
{
"merchant_ref": "202209082013GAEGBCB",
"meta": {
"account_number": "1234567890"
},
"trx_ref": "test-ref-123",
"status": "successful",
"session_id": "some-session-id",
"type": "transfer",
"secret": "your_webhook_secret"
}
- 📦 Modular MVC structure
- 🔒 Webhook verification
- 🛠️ Knex.js for DB abstraction
- 🧪 Full test suite (Jest + Supertest)
- 🧰 Utility for test user creation and auth mocking
Built with ❤️ by Josiah Gerald