Skip to content

Commit

Permalink
fix: sets not working when fetching with name
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviortheking committed Sep 25, 2024
1 parent 4700618 commit b9dae44
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .bruno/sets/Get a card by set name.bru
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions .bruno/sets/Get a set by name.bru
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/src/V2/endpoints/jsonEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand All @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions server/src/libs/QueryEngine/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b9dae44

Please sign in to comment.