Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
2.2 kB · 53 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { loggerTest } from "@foxxmd/logging";import { initServer } from "../server/index.ts";import ScrobbleClients from "../scrobblers/ScrobbleClients.ts";import { WildcardEmitter } from "../common/WildcardEmitter.ts";import ScrobbleSources from "../sources/ScrobbleSources.ts";import { generateOpenApiSpec } from "@minisylar/express-typed-router";import { writeFileSync } from "node:fs";import { resolve } from "path";import { projectRootDir } from "../common/infrastructure/Atomic.ts";import { stripIndents } from "common-tags";
const description = stripIndents`The Multi-Scrobbler server API is documented in **OpenAPI format** and includesendpoints useful for programatically interacting with your \`Play\` data and the various **Sources**/**Clients**you have configured.
Additionally, the **Ingress** category endpoints document the body/query shape required to make a successful api call for [Ingress-based Sources.](/configuration/sources/?sourceComm=ingress#by-communication-method)
:::tip
If you not using Ingress-based Sources or trying to write an application to use the MS API, you do notnot need to use this docs section.
:::
:::important
The endpoints documented here, other than those in Ingress categories, are **subject to change until a release declares them stable.**
:::
`
export const getOpenApiDoc = async () => { const internalConfig = { localUrl: new URL('https://example.com'), configDir: 'fake', logger: loggerTest, version: 'test' }; const clients = new ScrobbleClients(new WildcardEmitter(), new WildcardEmitter(), internalConfig, loggerTest); const sources = new ScrobbleSources(new WildcardEmitter(), internalConfig, loggerTest);
const [app, router] = await initServer({sources, clients}, {testMode: true}); const spec = await generateOpenApiSpec(router, { title: 'Multi-Scrobbler API', version: '0.1.0', description: description }); return spec;}
export const writeOpenApiDoc = async () => { const spec = await getOpenApiDoc(); writeFileSync(resolve(projectRootDir, 'docsite/static/openapi.json'), JSON.stringify(spec));}
await writeOpenApiDoc();