Skip to content

Commit

Permalink
Merge pull request #42 from decentraland/fix/missing-picked-by-param
Browse files Browse the repository at this point in the history
fix: add missing param pickedBy read from auth context
  • Loading branch information
juanmahidalgo authored Aug 15, 2023
2 parents 26babfe + 9089f26 commit 8098c56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/controllers/handlers/catalog-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function createCatalogHandler(
const limit = params.getNumber('first', DEFAULT_PAGE_SIZE)
const offset = params.getNumber('skip', 0)
// @TODO: add favorites logic
// const pickedBy: string | undefined = context.verification?.auth.toLowerCase()
const pickedBy: string | undefined = context.verification?.auth.toLowerCase()

return asJSON(async () => {
return await catalog.fetch({
Expand All @@ -32,7 +32,7 @@ export function createCatalogHandler(
sortDirection,
onlyListing,
onlyMinting,
// pickedBy,
pickedBy,
...getItemsParams(params)
})
})
Expand Down
12 changes: 11 additions & 1 deletion src/controllers/routes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Router } from '@well-known-components/http-server'
import * as authorizationMiddleware from 'decentraland-crypto-middleware'
import { GlobalContext } from '../types'
import { createCatalogHandler } from './handlers/catalog-handler'
import { pingHandler } from './handlers/ping-handler'

const FIVE_MINUTES = 5 * 60 * 1000

// We return the entire router because it will be easier to test than a whole server
export async function setupRouter(globalContext: GlobalContext): Promise<Router<GlobalContext>> {
const { components } = globalContext
const router = new Router<GlobalContext>()

router.get('/ping', pingHandler)
router.get('/v1/catalog', createCatalogHandler(components))
router.get(
'/v1/catalog',
authorizationMiddleware.wellKnownComponents({
optional: true,
expiration: FIVE_MINUTES
}),
createCatalogHandler(components)
)

return router
}

0 comments on commit 8098c56

Please sign in to comment.