generated from bennycode/ts-node-starter
-
Notifications
You must be signed in to change notification settings - Fork 62
/
init-client.ts
28 lines (23 loc) · 956 Bytes
/
init-client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {CoinbasePro} from '../index.js';
import 'dotenv-defaults/config';
export function initClient(): CoinbasePro {
if (process.env.USE_SANDBOX === 'true') {
console.info("Using Coinbase Pro's public sandbox with API key...");
return new CoinbasePro({
apiKey: process.env.COINBASE_PRO_SANDBOX_API_KEY!,
apiSecret: process.env.COINBASE_PRO_SANDBOX_API_SECRET!,
passphrase: process.env.COINBASE_PRO_SANDBOX_PASSPHRASE!,
useSandbox: true,
});
} else if (process.env.USE_SANDBOX === 'false') {
console.info("Using Coinbase Pro's production environment with API key...");
return new CoinbasePro({
apiKey: process.env.COINBASE_PRO_API_KEY!,
apiSecret: process.env.COINBASE_PRO_API_SECRET!,
passphrase: process.env.COINBASE_PRO_PASSPHRASE!,
useSandbox: false,
});
}
console.info("Using Coinbase Pro's production environment without API key...");
return new CoinbasePro();
}