Skip to content

Commit 81c87ec

Browse files
committed
Use constants for request limits
1 parent 56d9855 commit 81c87ec

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/v3/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ export const TWENTY_FOUR_HOURS = 24 * ONE_HOUR
55

66
export const LEADERBOARD_KEY = 'edgerates:topAssets'
77
export const TOKEN_TYPES_KEY = 'tokenTypes'
8+
9+
export const CRYPTO_LIMIT = 100
10+
export const FIAT_LIMIT = 256

src/v3/router.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { ExpressRequest } from 'serverlet/express'
44

55
import { config } from '../config'
66
import { slackPoster } from '../utils/postToSlack'
7-
import { ONE_MINUTE } from './constants'
7+
import { CRYPTO_LIMIT, FIAT_LIMIT, ONE_MINUTE } from './constants'
88
import { getRates } from './getRates'
99
import { dbSettings } from './providers/couch'
1010
import {
@@ -26,11 +26,11 @@ const fixIncomingGetRatesParams = (
2626

2727
const params = asIncomingGetRatesParams(rawParams)
2828

29-
if (params.crypto.length > 100) {
30-
throw new Error('crypto array must be less than 100')
29+
if (params.crypto.length > CRYPTO_LIMIT) {
30+
throw new Error(`crypto array must be less than ${CRYPTO_LIMIT}`)
3131
}
32-
if (params.fiat.length > 256) {
33-
throw new Error('fiat array must be less than 256')
32+
if (params.fiat.length > FIAT_LIMIT) {
33+
throw new Error(`fiat array must be less than ${FIAT_LIMIT}`)
3434
}
3535
if (params.targetFiat !== 'USD') {
3636
throw new Error('targetFiat must be USD')

0 commit comments

Comments
 (0)