File tree 1 file changed +18
-6
lines changed
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const runExample = require ( '../util/run_example' )
3
+ const dotenv = require ( 'dotenv' )
4
+ const D = require ( 'debug' )
5
+ const WSv2 = require ( '../../lib/transports/ws2' )
6
+ const debug = D ( '>' )
7
+ debug . enabled = true
8
+
9
+ dotenv . config ( )
10
+ const { API_KEY , API_SECRET } = process . env
11
+
12
+ async function execute ( ) {
13
+ const ws = new WSv2 ( {
14
+ apiKey : API_KEY ,
15
+ apiSecret : API_SECRET
16
+ } )
17
+ ws . on ( 'error' , e => debug ( 'WSv2 error: %s' , e . message | e ) )
4
18
5
- module . exports = runExample ( {
6
- name : 'ws2-auth' ,
7
- ws : { env : true } // manually open/auth to show usage
8
- } , async ( { ws, debug } ) => {
9
19
// register a callback for any order snapshot that comes in (account orders)
10
20
ws . onOrderSnapshot ( { } , ( orders ) => {
11
21
debug ( `order snapshot: ${ JSON . stringify ( orders , null , 2 ) } ` )
@@ -18,4 +28,6 @@ module.exports = runExample({
18
28
debug ( 'authenticated' )
19
29
20
30
// do something with authenticated ws stream
21
- } )
31
+ }
32
+
33
+ execute ( )
You can’t perform that action at this time.
0 commit comments