I want to create the api for my application in replit and then move it to a host and because this is just a prototype, i really dont care about security so please give me the answer and dont say ThIs iS sO InSEcuRe
So im working on an application that users can enter someone's name and call them or see the caller's name, age, gender and reason of calling. First i started by using variables for saving data and then moved to replit DB. But when i did that and tried GETting /call/09876543210/09123456789 it gave me a replit error page
Heres the code:
http.createServer((req, res) => {
console.log(req.url);
if (req.method == "GET"){
if (req.url.substring(1).startsWith("call/")){
calls.get(req.url.susbtring(1)[1]).then(value => {
if(!value){
calls.set(req.url.substring(1).split("/")[1],req.url.substring(1).split("/")[2]).then(() => {
res.end("DONE");
});
}
});
}
if (req.url.startsWith("/anyCallsToNumber/")){
calls.get(req.url.replace("/anyCallsToNumber/","")).then(value => {
if(value){
res.end(value);
}else res.end("NO");
});
}
if(req.url.startsWith("/answerCall/")){
calls.get(req.url.replace("/answerCall/","")).then(value => {
if(value){
calls.delete(req.url.replace("/answerCall/","")).then(() => {
res.end("DONE");
});
}else res.end("UNAVAILABLE");
});
}
if (req.url.startsWith("/getUserFromNumber/")){
if(dataByNumber[req.url.replace("/getUserFromNumber/","")]){
res.end(JSON.stringify(dataByNumber[req.url.replace("/getUserFromNumber/","")]));
}else res.end("UNKNOWN");
}
if (req.url.startsWith("/getUserFromName/")){
if(dataByNumber[req.url.replace("/getUserFromName/","")]){
res.end(JSON.stringify(dataByName[req.url.replace("/getUserFromName/","")]));
}else res.end("UNKNOWN");
}
}
res.end();
}).listen(8080);