Rewrite getRouteDescriptions, fix message route not appearing in openapi spec

This commit is contained in:
Madeline
2023-04-16 01:51:52 +10:00
parent a263ebb1e5
commit b438f2b071
14 changed files with 247 additions and 120 deletions
+1 -2
View File
@@ -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();
+1 -2
View File
@@ -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();
+2 -25
View File
@@ -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({