[api] update to reflect backend

This commit is contained in:
derpystuff 2022-05-26 14:34:08 +02:00
parent 41721f941f
commit 2498e8ac93
2 changed files with 103 additions and 13 deletions

View file

@ -8,26 +8,38 @@ const Hosts = Object.freeze({
const Api = Object.freeze({
HOST: Hosts.prod,
GOOGLE_PERSPECTIVE: '/google/perspective/analyze',
GOOGLE_TRANSLATE: '/google/translate/text',
GOOGLE_VISION_COLORS: '/google/vision/colors',
GOOGLE_VISION_FACES: '/google/vision/faces',
GOOGLE_VISION_LABELS: '/google/vision/labels',
GOOGLE_VISION_OCR: '/google/vision/ocr',
GOOGLE_VISION_SAFETY_LABELS: '/google/vision/safety',
GOOGLE_VISION_WEBDETECTION: '/google/vision/webdetection',
SEARCH_LYRICS: '/search/lyrics',
IMAGE_DEEPDREAM: '/image/deepdream',
IMAGE_SUPERRESOLUTION: '/image/superresolution',
IMAGE_WAIFU2X: '/image/waifu2x',
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
PHOTOFUNIA_YACHT: '/photofunia/yacht',
SEARCH_AUDIO: '/search/audio',
SEARCH_GOOGLE: '/search/google',
SEARCH_GOOGLE_IMAGES: '/search/google-images',
SEARCH_BING: '/search/bing',
SEARCH_BING_IMAGES: '/search/bing-images',
SEARCH_GOOGLE: '/search/google',
SEARCH_GOOGLE_IMAGES: '/search/google-images',
SEARCH_LYRICS: '/search/lyrics',
SEARCH_WOLFRAM_ALPHA: '/search/wolfram-alpha',
SEARCH_YOUTUBE: '/search/youtube',
PHOTOFUNIA_YACHT: '/photofunia/yacht',
PHOTOFUNIA_RETRO_WAVE: '/photofunia/retro-wave',
TTS_IMTRANSLATOR: '/tts/imtranslator',
TTS_POLLY: '/tts/polly',
TTS_TIKTOK: '/tts/tiktok',
TTS_VOICEFORGE: '/tts/voiceforge',
IMAGE_DEEPDREAM: '/image/deepdream',
IMAGE_WAIFU2X: '/image/waifu2x',
IMAGE_SUPERRESOLUTION: '/image/superresolution',
INFERKIT: '/utils/inferkit',
UTILS_INFERKIT: '/utils/inferkit',
UTILS_SCREENSHOT: '/utils/screenshot',
})
const Static = Object.freeze({

View file

@ -41,12 +41,56 @@ async function request(path, type, headers, args, host) {
throw new Error("unsupported, must either use GET or POST");
}
module.exports.googlePerspective = async function(context, text){
return await request(Api.GOOGLE_PERSPECTIVE, "GET", {}, {
text: text
})
}
module.exports.googleTranslate = async function(context, text, to, from){
return await request(Api.GOOGLE_TRANSLATE, "GET", {}, {
text: text,
to: to,
from: from
})
}
module.exports.googleVisionColors = async function(context, url){
return await request(Api.GOOGLE_VISION_COLORS, "GET", {}, {
url: url
})
}
module.exports.googleVisionFaces = async function(context, url){
return await request(Api.GOOGLE_VISION_FACES, "GET", {}, {
url: url
})
}
module.exports.googleVisionLabels = async function(context, url){
return await request(Api.GOOGLE_VISION_LABELS, "GET", {}, {
url: url
})
}
module.exports.googleVisionOcr = async function(context, url){
return await request(Api.GOOGLE_VISION_OCR, "GET", {}, {
url: url
})
}
module.exports.googleVisionSafetyLabels = async function(context, url){
return await request(Api.GOOGLE_VISION_SAFETY_LABELS, "GET", {}, {
url: url
})
}
module.exports.googleVisionWebDetection = async function(context, url){
return await request(Api.GOOGLE_VISION_WEBDETECTION, "GET", {}, {
url: url
})
}
module.exports.searchAudio = async function(context, url){
return await request(Api.SEARCH_AUDIO, "GET", {}, {
url: url
@ -129,12 +173,46 @@ module.exports.superresolution = async function(context, url){
})
}
module.exports.imtranslator = async function(context, text, voice){
return await request(Api.TTS_IMTRANSLATOR, "GET", {}, {
text: text,
voice: voice
})
}
module.exports.polly = async function(context, text, voice){
return await request(Api.TTS_POLLY, "GET", {}, {
text: text,
voice: voice
})
}
module.exports.tiktok = async function(context, text, voice){
return await request(Api.TTS_TIKTOK, "GET", {}, {
text: text,
voice: voice
})
}
module.exports.voiceforge = async function(context, text, voice){
return await request(Api.TTS_VOICEFORGE, "GET", {}, {
text: text,
voice: voice
})
}
module.exports.inferkit = async function(context, input){
return await request(Api.INFERKIT, "GET", {}, {
return await request(Api.UTILS_INFERKIT, "GET", {}, {
input: input
})
}
module.exports.screenshot = async function(context, url){
return await request(Api.UTILS_SCREENSHOT, "GET", {}, {
url: url
})
}
module.exports.emojiTwitter = async function(codepoint){
return Static.HOST + Static.TWITTER(codepoint)
}