4.3: open api + post method for main endpoint

This commit is contained in:
wukko
2022-11-12 22:40:11 +06:00
parent 4d06554256
commit 316e6423f4
18 changed files with 268 additions and 86 deletions

View File

@@ -22,7 +22,7 @@ export function apiJSON(type, obj) {
pickerType = "images"
break;
}
return { status: 200, body: { status: "picker", pickerType: pickerType, url: obj.picker, audio: audio } };
return { status: 200, body: { status: "picker", pickerType: pickerType, picker: obj.picker, audio: audio } };
default:
return { status: 400, body: { status: "error", text: "Bad Request" } };
}
@@ -75,3 +75,35 @@ export function unicodeDecode(str) {
return String.fromCharCode(parseInt(unicode.replace(/\\u/g, ""), 16));
});
}
export function checkJSONPost(obj) {
let def = {
vFormat: "mp4",
vQuality: "hig",
aFormat: "mp3",
isAudioOnly: false,
isNoTTWatermark: false,
isTTFullAudio: false
}
let booleanOnly = ["isAudioOnly", "isNoTTWatermark", "isTTFullAudio"]
try {
let objKeys = Object.keys(obj);
if (objKeys.length < 8) {
let objKeys = Object.keys(obj);
let defKeys = Object.keys(def);
for (let i in objKeys) {
if (defKeys.includes(objKeys[i])) {
if (booleanOnly.includes(objKeys[i])) {
def[objKeys[i]] = obj[objKeys[i]] ? true : false
} else {
def[objKeys[i]] = obj[objKeys[i]]
}
}
}
return def
} else {
return false
}
} catch (e) {
return false;
}
}