This repository was archived by the owner on May 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (35 loc) · 1.24 KB
/
index.js
File metadata and controls
41 lines (35 loc) · 1.24 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
require('source-map-support').install();
const Authentication = require('./auth').default;
const headers = require('./headers').default;
const Accounts = require('./accounts').default;
const Orders = require('./orders').default;
const Data = require('./data').default;
const Quotes = require('./quotes').default;
const config = require('./config').default;
const HttpsWorker = require('./network/https').default;
/**
* Builds a new Trade session with an independent authentication
* state, facilitating concurrent usage of the Trade APIs.
*
* The headers and config module, however, is mutually shared between
* all sessions.
*/
const Session = () => {
const worker = new HttpsWorker();
const data = new Data(worker);
return {
auth: new Authentication(worker),
headers,
accounts: new Accounts(worker),
orders: new Orders(worker, data),
quotes: new Quotes(worker, data),
data,
config,
};
};
// We need a default session exported for backwards compatibility reasons,
// but also because not everyone cares about concurrent usages.
const defaultSession = new Session();
// Allow the creation of multiple sessions through a Session() constructor
defaultSession.Session = () => new Session();
module.exports = defaultSession;