'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' || !req.query.code.trim()) { res.json({ status: 'NOT-OK', error: 'INVALID-PARAMETER', message: 'Undefined parameter: code', }); } const reply = await modem.executeUSSD(req.query.code.trim()); res.json({ status: 'OK', error: false, message: 'USSD executed', result: reply, }); } router.get('/', handlerIndex);