Have ideas to improve npm?Join in the discussion! »

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

    0.1.5 • Public • Published

    ussd-router

    ussd-router is a free utility for easy routing in USSD applications.

    See also:

    Install

    npm i ussd-router

    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

    Install

    npm i ussd-router

    DownloadsWeekly Downloads

    43

    Version

    0.1.5

    License

    GPL-3.0

    Unpacked Size

    48.1 kB

    Total Files

    16

    Last publish

    Collaborators

    • avatar