Rewrite getRouteDescriptions, fix message route not appearing in openapi spec
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { TenorMediaTypes } from "@spacebar/util";
|
||||
import { TenorMediaTypes, getGifApiKey, parseGifResult } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import fetch from "node-fetch";
|
||||
import ProxyAgent from "proxy-agent";
|
||||
import { getGifApiKey, parseGifResult } from "./trending";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import { TenorMediaTypes } from "@spacebar/util";
|
||||
import { TenorMediaTypes, getGifApiKey, parseGifResult } from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import fetch from "node-fetch";
|
||||
import ProxyAgent from "proxy-agent";
|
||||
import { getGifApiKey, parseGifResult } from "./trending";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -18,40 +18,17 @@
|
||||
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Config,
|
||||
TenorCategoriesResults,
|
||||
TenorGif,
|
||||
TenorTrendingResults,
|
||||
getGifApiKey,
|
||||
parseGifResult,
|
||||
} from "@spacebar/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import fetch from "node-fetch";
|
||||
import ProxyAgent from "proxy-agent";
|
||||
|
||||
const router = Router();
|
||||
|
||||
export function parseGifResult(result: TenorGif) {
|
||||
return {
|
||||
id: result.id,
|
||||
title: result.title,
|
||||
url: result.itemurl,
|
||||
src: result.media[0].mp4.url,
|
||||
gif_src: result.media[0].gif.url,
|
||||
width: result.media[0].mp4.dims[0],
|
||||
height: result.media[0].mp4.dims[1],
|
||||
preview: result.media[0].mp4.preview,
|
||||
};
|
||||
}
|
||||
|
||||
export function getGifApiKey() {
|
||||
const { enabled, provider, apiKey } = Config.get().gif;
|
||||
if (!enabled) throw new HTTPError(`Gifs are disabled`);
|
||||
if (provider !== "tenor" || !apiKey)
|
||||
throw new HTTPError(`${provider} gif provider not supported`);
|
||||
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
router.get(
|
||||
"/",
|
||||
route({
|
||||
|
||||
Reference in New Issue
Block a user