-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
50 lines (48 loc) · 2.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import ResponseBuilder from "../../../edge-src/common/ResponseBuilder";
import JustListenDef from "../../../edge-src/api-definitions/JustListenDef";
import SearchEpisodesDef from "../../../edge-src/api-definitions/SearchEpisodesDef";
import SearchPodcastsDef from "../../../edge-src/api-definitions/SearchPodcastsDef";
import GetGenresDef from '../../../edge-src/api-definitions/GetGenresDef';
import BestPodcastsDef from '../../../edge-src/api-definitions/BestPodcastsDef';
import GetLanguagesDef from "../../../edge-src/api-definitions/GetLanguagesDef";
import GetRegionsDef from "../../../edge-src/api-definitions/GetRegionsDef";
import GetEpisodeDef from "../../../edge-src/api-definitions/GetEpisodeDef";
import GetPodcastDef from "../../../edge-src/api-definitions/GetPodcastDef";
// Example spec: https://platform.openai.com/docs/plugins/getting-started/openapi-definition
// - 200 characters max for each API endpoint description/summary field in API specification
// - 200 characters max for each API param description field in API specification
const openapiSpec = (params) => ({
openapi: '3.1.0',
info: {
title: 'Listen Notes Podcast Search Engine and Database Plugin',
description: 'A plugin that allows the user to discover podcasts and episodes using ChatGPT.',
version: '2.0.0',
},
servers: [
{
url: `${params.baseUrl}/api/v2`,
},
],
paths: {
...params.paths,
},
})
export async function onRequestGet(context) {
const {data} = context
const responseBuilder = new ResponseBuilder(context)
const params = {
baseUrl: data.baseUrl,
paths: {
...new SearchPodcastsDef().openApiPathSpec(),
...new SearchEpisodesDef().openApiPathSpec(),
...new BestPodcastsDef().openApiPathSpec(),
...new JustListenDef().openApiPathSpec(),
...new GetGenresDef().openApiPathSpec(),
...new GetLanguagesDef().openApiPathSpec(),
...new GetRegionsDef().openApiPathSpec(),
...new GetEpisodeDef().openApiPathSpec(),
...new GetPodcastDef().openApiPathSpec(),
},
}
return responseBuilder.getJsonResponse(openapiSpec(params))
}