ussd-router
v0.1.6
Published
A free utility for easy routing in USSD applications
Downloads
45
Maintainers
Readme
ussd-router
ussd-router
is a free utility for easy routing in USSD applications.
Install
npm i ussd-router
See also:
Example usage (simple)
import { ussdRouter } from 'ussd-router';
const text1 = ussdRouter('544*1*2'); // '544*1*2'
const text2 = ussdRouter('544*1*2*00*3'); // '544*1*3'
const text3 = ussdRouter('544*1*2*0*1*2'); // '1*2'
const text4 = ussdRouter('544*1*2*0*1*2*00*3'); // '1*3'
Example usage (with express)
import express from 'express';
import { ussdRouter } from 'ussd-router';
// ...
app.post('/webhook/ussd', (req, res) => {
const { body: { text: rawText } } = req;
const text = ussdRouter(rawText);
if (text === '1') {
res
.status(200)
.send('View: \n1. My account number \n2. My balance');
}
// ...
});
Dev
# install dependencies
npm i
# build
npm run build
# lint
npm run lint
# test
npm t