mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-07-12 12:55:25 +00:00
feat: Add openapi explorer (#529)
This commit is contained in:
18
server/src/V2/endpoints/openapi.ts
Normal file
18
server/src/V2/endpoints/openapi.ts
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
import express from 'express'
|
||||
import fs from 'node:fs'
|
||||
import swaggerUi from 'swagger-ui-express'
|
||||
import YAML from 'yaml'
|
||||
|
||||
const file = fs.readFileSync('./public/v2/openapi.yaml', 'utf8')
|
||||
const swaggerDocument = YAML.parse(file)
|
||||
|
||||
const server = express.Router()
|
||||
|
||||
server.use('/', swaggerUi.serve, swaggerUi.setup(swaggerDocument, {
|
||||
customCss: '.topbar { display: none }',
|
||||
customfavIcon: '/favicon.ico',
|
||||
customSiteTitle: 'Openapi documentation - TCGdex API'
|
||||
}))
|
||||
|
||||
export default server
|
@ -1,10 +1,11 @@
|
||||
import express, { type Response } from 'express'
|
||||
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
||||
import openapi from './V2/endpoints/openapi'
|
||||
import graphql from './V2/graphql'
|
||||
import cluster from 'node:cluster'
|
||||
import { availableParallelism } from "node:os"
|
||||
import { Errors, sendError } from './libs/Errors'
|
||||
import status from './status'
|
||||
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
||||
import graphql from './V2/graphql'
|
||||
import * as Sentry from "@sentry/node"
|
||||
|
||||
// Glitchtip will only start if the DSN is set :D
|
||||
@ -103,6 +104,7 @@ if (cluster.isPrimary) {
|
||||
|
||||
// Setup GraphQL
|
||||
server.use(`/v${VERSION}/graphql`, graphql)
|
||||
server.use(`/v${VERSION}/openapi`, openapi)
|
||||
|
||||
// Setup JSON endpoints
|
||||
server.use(`/v${VERSION}`, jsonEndpoints)
|
||||
|
Reference in New Issue
Block a user