-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
231 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,32 @@ | ||
import { KuaiConfig } from '@ckb-js/kuai-core'; | ||
|
||
let redisOpt = undefined; | ||
let redisOpt = undefined | ||
if (process.env.REDIS_OPT) { | ||
try { | ||
redisOpt = JSON.parse(process.env.REDIS_OPT); | ||
redisOpt = JSON.parse(process.env.REDIS_OPT) | ||
} catch (error) { | ||
//ignore error, if error redisOpt will be undefined | ||
} | ||
} | ||
|
||
// fallback to REDISUSER due to https://github.com/ckb-js/kuai/pull/423#issuecomment-1668983983 | ||
const REDIS_USER = redisOpt?.username ?? process.env.REDISUSER; | ||
const REDIS_PASSWORD = redisOpt?.password ?? process.env.REDISPASSWORD; | ||
const REDIS_HOST = process.env.REDIS_HOST ?? process.env.REDISHOST; | ||
const REDIS_PORT = process.env.REDIS_PORT ?? process.env.REDISPORT; | ||
const REDIS_USER = redisOpt?.username ?? process.env.REDISUSER | ||
const REDIS_PASSWORD = redisOpt?.password ?? process.env.REDISPASSWORD | ||
const REDIS_HOST = process.env.REDIS_HOST ?? process.env.REDISHOST | ||
const REDIS_PORT = process.env.REDIS_PORT ?? process.env.REDISPORT | ||
|
||
const redisAuth = REDIS_USER && REDIS_PASSWORD ? { username: REDIS_USER, password: REDIS_PASSWORD } : undefined; | ||
const redisAuth = REDIS_USER && REDIS_PASSWORD ? { username: REDIS_USER, password: REDIS_PASSWORD } : undefined | ||
|
||
const config: KuaiConfig = { | ||
const config = { | ||
port: 3000, | ||
redisPort: REDIS_HOST ? +REDIS_HOST : undefined, | ||
redisHost: REDIS_PORT, | ||
network: process.env.NETWORK || 'testnet', | ||
redisOpt: | ||
redisOpt || redisAuth | ||
? { | ||
...redisOpt, | ||
...redisAuth, | ||
} | ||
: undefined, | ||
network: 'testnet', | ||
ckbChain: { | ||
rpcUrl: 'http://127.0.0.1:8114', | ||
prefix: 'ckt', | ||
}, | ||
}; | ||
} | ||
|
||
export default config; | ||
export default config |
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
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
Oops, something went wrong.