mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-23 11:22:10 +00:00
fix: sets not working when fetching with name
This commit is contained in:
parent
4700618047
commit
b9dae445b1
16
.bruno/sets/Get a card by set name.bru
Normal file
16
.bruno/sets/Get a card by set name.bru
Normal 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
|
||||||
|
}
|
16
.bruno/sets/Get a set by name.bru
Normal file
16
.bruno/sets/Get a set by name.bru
Normal 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
|
||||||
|
}
|
14
Dockerfile
14
Dockerfile
@ -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
|
# go to work folder
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
@ -28,7 +28,7 @@ rm -rf node_modules && \
|
|||||||
bun install --frozen-install --production
|
bun install --frozen-install --production
|
||||||
|
|
||||||
# go to another VM
|
# 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
|
# inform software to be in production
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
@ -40,11 +40,11 @@ USER bun
|
|||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# copy from build image
|
# copy from build image
|
||||||
COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/generated ./generated
|
COPY --chown=bun:bun --from=build /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 /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 /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 /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/package.json ./package.json
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
@ -251,6 +251,7 @@ server
|
|||||||
*/
|
*/
|
||||||
.get('/:lang/:endpoint/:id/:subid', (req: CustomRequest, res) => {
|
.get('/:lang/:endpoint/:id/:subid', (req: CustomRequest, res) => {
|
||||||
let { id, lang, endpoint, subid } = req.params
|
let { id, lang, endpoint, subid } = req.params
|
||||||
|
console.log(req.params)
|
||||||
|
|
||||||
if (subid.endsWith('.json')) {
|
if (subid.endsWith('.json')) {
|
||||||
subid = subid.replace('.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
|
// allow the dev to use a non prefixed value like `10` instead of `010` for newer sets
|
||||||
result = Card
|
result = Card
|
||||||
// @ts-expect-error normal behavior until the filtering is more fiable
|
// @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
|
break
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -384,6 +384,9 @@ function filterItem(value: any, query: QueryValues<AllowedValues>): boolean {
|
|||||||
* strict value check by default
|
* strict value check by default
|
||||||
*/
|
*/
|
||||||
if (!(typeof query === 'object')) {
|
if (!(typeof query === 'object')) {
|
||||||
|
if (typeof query === 'string' && typeof value === 'string') {
|
||||||
|
return query.toLowerCase() === value.toLowerCase()
|
||||||
|
}
|
||||||
return query === value
|
return query === value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user