ussd-router
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

ussd-router

build, run linter & tests npm npm bundle size npm

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

Package Sidebar

Install

npm i ussd-router

Weekly Downloads

10

Version

0.1.6

License

GPL-3.0

Unpacked Size

46.3 kB

Total Files

16

Last publish

Collaborators

  • tawn33y