mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-06-14 00:29:19 +00:00
2258
server/package-lock.json
generated
Normal file
2258
server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,12 +17,15 @@
|
||||
"express": "^4",
|
||||
"graphql": "^15",
|
||||
"graphql-http": "^1.22.1",
|
||||
"ruru": "^2.0.0-beta.14"
|
||||
"ruru": "^2.0.0-beta.14",
|
||||
"swagger-ui-express": "^5.0.1",
|
||||
"yaml": "^2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/apicache": "^1",
|
||||
"@types/express": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/swagger-ui-express": "^4.1.6",
|
||||
"glob": "^10",
|
||||
"typescript": "^4"
|
||||
}
|
||||
|
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,5 +1,6 @@
|
||||
import express, { type Response } from 'express'
|
||||
import jsonEndpoints from './V2/endpoints/jsonEndpoints'
|
||||
import openapi from './V2/endpoints/openapi'
|
||||
import graphql from './V2/graphql'
|
||||
import { Errors, sendError } from './libs/Errors'
|
||||
import status from './status'
|
||||
@ -66,6 +67,7 @@ server.use(express.static('./public'))
|
||||
|
||||
// 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