1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-07-12 04:55:24 +00:00

fix(server): Server not correctly handling +

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
2023-01-11 21:18:31 +01:00
parent 2b23503864
commit 4b340733d7
2 changed files with 17 additions and 11 deletions

View File

@ -28,7 +28,10 @@ const endpointToField: Record<string, keyof SDKCard> = {
"variants": "variants", "variants": "variants",
} }
// server server
// Midleware that handle caching
.use(apicache.middleware('1 day', (req: Request) => req.method === 'GET', {}))
// .get('/cache/performance', (req, res) => { // .get('/cache/performance', (req, res) => {
// res.json(apicache.getPerformance()) // res.json(apicache.getPerformance())
// }) // })
@ -38,9 +41,12 @@ const endpointToField: Record<string, keyof SDKCard> = {
// res.json(apicache.getIndex()) // res.json(apicache.getIndex())
// }) // })
server // Midleware that handle url transformation
.use(apicache.middleware('1 day', (req: Request) => req.method === 'GET', {})) .use((req, res, next) => {
// this is ugly BUT it fix the problem with + not becoming spaces
req.url = req.url.replace(/\+/g, ' ')
next()
})
/** /**

View File

@ -1,5 +1,5 @@
{ {
"extends": "./node_modules/@dzeio/config/tsconfig.base", "extends": "./node_modules/@dzeio/config/tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"outDir": "dist" "outDir": "dist"
}, },