1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-22 02:42:09 +00:00

fix: sets not working when fetching with name

This commit is contained in:
Florian Bouillon 2024-09-26 00:31:10 +02:00
parent 4700618047
commit b9dae445b1
5 changed files with 44 additions and 8 deletions

View File

@ -0,0 +1,16 @@
meta {
name: Get a card by set name
type: http
seq: 6
}
get {
url: {{BASE_URL}}/v2/en/sets/Crystal%20Guardians/10
body: none
auth: none
}
assert {
res.status: eq 200
res.body.id: eq ex14-10
}

View File

@ -0,0 +1,16 @@
meta {
name: Get a set by name
type: http
seq: 5
}
get {
url: {{BASE_URL}}/v2/en/sets/Crystal%20Guardians
body: none
auth: none
}
assert {
res.status: eq 200
res.body.id: eq ex14
}

View File

@ -1,4 +1,4 @@
FROM docker.io/oven/bun:1-alpine as BUILD_IMAGE
FROM docker.io/oven/bun:1-alpine AS build
# go to work folder
WORKDIR /usr/src/app
@ -28,7 +28,7 @@ rm -rf node_modules && \
bun install --frozen-install --production
# go to another VM
FROM docker.io/oven/bun:1-alpine as PROD_IMAGE
FROM docker.io/oven/bun:1-alpine AS prod
# inform software to be in production
ENV NODE_ENV=production
@ -40,11 +40,11 @@ USER bun
WORKDIR /usr/src/app
# copy from build image
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/generated ./generated
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/node_modules ./node_modules
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/src ./src
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/public ./public
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/package.json ./package.json
COPY --chown=bun:bun --from=build /usr/src/app/server/generated ./generated
COPY --chown=bun:bun --from=build /usr/src/app/server/node_modules ./node_modules
COPY --chown=bun:bun --from=build /usr/src/app/server/src ./src
COPY --chown=bun:bun --from=build /usr/src/app/server/public ./public
COPY --chown=bun:bun --from=build /usr/src/app/server/package.json ./package.json
# Expose port
EXPOSE 3000

View File

@ -251,6 +251,7 @@ server
*/
.get('/:lang/:endpoint/:id/:subid', (req: CustomRequest, res) => {
let { id, lang, endpoint, subid } = req.params
console.log(req.params)
if (subid.endsWith('.json')) {
subid = subid.replace('.json', '')
@ -270,7 +271,7 @@ server
// allow the dev to use a non prefixed value like `10` instead of `010` for newer sets
result = Card
// @ts-expect-error normal behavior until the filtering is more fiable
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, 'set.id': id })?.full()
.findOne(lang, { localId: { $or: [subid.padStart(3, '0'), subid]}, $or: [{ 'set.id': id }, { 'set.name': id }] })?.full()
break
}
if (!result) {

View File

@ -384,6 +384,9 @@ function filterItem(value: any, query: QueryValues<AllowedValues>): boolean {
* strict value check by default
*/
if (!(typeof query === 'object')) {
if (typeof query === 'string' && typeof value === 'string') {
return query.toLowerCase() === value.toLowerCase()
}
return query === value
}