'use strict'; const express = require('express'); const modem = require('../modem'); const router = express.Router(); module.exports = router; async function handlerIndex(req, res) { if (!req.query || !req.query.code || typeof req.query.code !== 'string') { res.json({ status: 'NOT-OK', error: 'INVALID-PARAMETER', message: 'Undefined parameter: code', }); return; } const reply = await modem.executeUSSD(req.query.code, req.query.include_cusd2); res.json({ status: 'OK', error: false, code: req.query.code, include_cusd2: req.query.include_cusd2, result: reply, message: 'USSD executed', }); } router.get('/', handlerIndex);