add: initial working poc

This commit is contained in:
2022-01-14 14:46:59 +03:00
commit 4372632d93
7 changed files with 290 additions and 0 deletions

30
src/request.js Normal file
View File

@@ -0,0 +1,30 @@
// npm imports
const phin = require("phin");
// module imports
const cache = require("./cache");
const util = require("./utils");
// proxy requests to ussd-server
// TODO: handle errors
async function proxy(phone, input = "") {
const sessionId = await cache.get(phone);
const { body } = await phin({
// TODO: get value from confini
url: "",
method: "POST",
parse: "string",
form: {
sessionId: sessionId,
phoneNumber: phone,
// TODO: get value from confini
serviceCode: "",
text: input,
},
});
return util.parseUssdResponse(body);
}
module.exports = { proxy };