37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
|
|
module.exports = {
|
|
name:"codeList",
|
|
async function(req, res){
|
|
let apiKey = req.headers.auth
|
|
|
|
if(apiKey == undefined){
|
|
res.json({code:51})
|
|
return
|
|
}
|
|
var userid
|
|
await commands.get("validate").check(apiKey).then(resp => {
|
|
userid = resp
|
|
}).catch(err => {
|
|
switch(err){
|
|
case 1: res.json({code:51}); break;
|
|
case 2: res.json({code:52}); break;
|
|
}
|
|
return
|
|
})
|
|
|
|
let output = {
|
|
code:50,
|
|
shortcodes:[]
|
|
}
|
|
|
|
let codes = await commands.get("query").function("SELECT idShortcode, dtOriginal, tbl_urls.dtTimestamp from tbl_urls, tbl_users where fiUser = idUser AND dtApiKey = ?",[apiKey])
|
|
for (let i = 0; i < codes.length; i++) {
|
|
output.shortcodes.push({
|
|
"shortcode": codes[i].idShortcode,
|
|
"destination": codes[i].dtOriginal,
|
|
"timestamp": codes[i].dtTimestamp
|
|
})
|
|
}
|
|
res.json(output)
|
|
}
|
|
} |