Skip to content

Commit

Permalink
test(fix): adjust asserted error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 committed Oct 29, 2023
1 parent 8bcda54 commit e92be30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 5 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface AppConfig {
beeApiUrl: string
beeDebugApiUrl: string
authorization?: string
allowlist?: string[]
hostname?: string
cidSubdomains?: boolean
ensSubdomains?: boolean
Expand Down Expand Up @@ -54,6 +55,7 @@ export type EnvironmentVariables = Partial<{
// Proxy
BEE_API_URL: string
AUTH_SECRET: string
ALLOWLIST: string

// Server
PORT: string
Expand Down Expand Up @@ -106,6 +108,7 @@ export function getAppConfig({
BEE_API_URL,
BEE_DEBUG_API_URL,
AUTH_SECRET,
ALLOWLIST,
CID_SUBDOMAINS,
ENS_SUBDOMAINS,
HOSTNAME,
Expand All @@ -117,6 +120,7 @@ export function getAppConfig({
beeApiUrl: BEE_API_URL || DEFAULT_BEE_API_URL,
beeDebugApiUrl: BEE_DEBUG_API_URL || DEFAULT_BEE_DEBUG_API_URL,
authorization: AUTH_SECRET,
allowlist: ALLOWLIST ? ALLOWLIST.split(',') : undefined,
cidSubdomains: CID_SUBDOMAINS === 'true',
ensSubdomains: ENS_SUBDOMAINS === 'true',
removePinHeader: REMOVE_PIN_HEADER ? REMOVE_PIN_HEADER === 'true' : true,
Expand Down Expand Up @@ -176,7 +180,7 @@ export function getStampsConfig({
throw new Error(
`config: please provide POSTAGE_DEPTH=${POSTAGE_DEPTH}, POSTAGE_AMOUNT=${POSTAGE_AMOUNT}, POSTAGE_TTL_MIN=${POSTAGE_TTL_MIN} ${
POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''
} for the feature to work`,
}for the feature to work`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Options {
beeApiUrl: string
removePinHeader: boolean
stampManager: StampsManager | null
allowlist?: string[]
}

export function createProxyEndpoints(app: Application, options: Options) {
Expand Down Expand Up @@ -45,7 +46,6 @@ async function fetchAndRespond(req: Request, res: Response, options: Options) {
validateStatus: status => status < 500,
responseType: 'arraybuffer',
})
console.log(response.headers)
if ((response.headers['content-disposition'] || '').includes('.html')) {

Check failure on line 49 in src/proxy.ts

View workflow job for this annotation

GitHub Actions / check (14.x)

Expected blank line before this statement
res.status(403).send('Forbidden')
return

Check failure on line 51 in src/proxy.ts

View workflow job for this annotation

GitHub Actions / check (14.x)

Expected blank line before this statement
Expand Down
14 changes: 6 additions & 8 deletions test/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
DEFAULT_BEE_API_URL,
DEFAULT_BEE_DEBUG_API_URL,
DEFAULT_HOSTNAME,
DEFAULT_PORT,
DEFAULT_POSTAGE_USAGE_THRESHOLD,
DEFAULT_POSTAGE_USAGE_MAX,
DEFAULT_POSTAGE_REFRESH_PERIOD,
DEFAULT_POSTAGE_USAGE_MAX,
DEFAULT_POSTAGE_USAGE_THRESHOLD,
EnvironmentVariables,
StampsConfig,
getAppConfig,
getServerConfig,
getStampsConfig,
EnvironmentVariables,
StampsConfig,
DEFAULT_BEE_API_URL,
} from '../src/config'

describe('getAppConfig', () => {
Expand Down Expand Up @@ -195,9 +195,7 @@ describe('getStampsConfig', () => {
}).toThrowError(
`config: please provide POSTAGE_DEPTH=${v.POSTAGE_DEPTH}, POSTAGE_AMOUNT=${v.POSTAGE_AMOUNT}, POSTAGE_TTL_MIN=${
v.POSTAGE_TTL_MIN
} ${v.POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''}or BEE_DEBUG_API_URL=${
v.BEE_DEBUG_API_URL
} for the feature to work`,
} ${v.POSTAGE_EXTENDSTTL === 'true' ? 'at least 60 seconds ' : ''}for the feature to work`,
)
})
})
Expand Down

0 comments on commit e92be30

Please sign in to comment.