generated from well-known-components/template-server
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from decentraland/fix/missing-picked-by-param
fix: add missing param pickedBy read from auth context
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |