forked from zackurben/alphavantage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (30 loc) · 921 Bytes
/
index.js
File metadata and controls
35 lines (30 loc) · 921 Bytes
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
'use strict';
require('dotenv').config();
const apiKey = 'AV_KEY';
/**
* The Alpha Vantage core module.
*/
module.exports = config => {
config = Object.assign({}, { key: process.env[apiKey] }, config);
// Check for config errors.
let errors = [];
['key'].forEach(prop => {
if (config[prop] === undefined) {
errors.push(prop);
}
});
if (errors.length) {
throw new Error(`Missing Alpha Vantage config settings: ${errors.join(', ')}`);
}
// Add the base url for submodules to use.
config.base = `https://www.alphavantage.co/query?apikey=${config.key}&`;
// Include all the submodules.
return {
util: require('./lib/util')(config),
data: require('./lib/data')(config),
forex: require('./lib/forex')(config),
crypto: require('./lib/crypto')(config),
technical: require('./lib/technical')(config),
performance: require('./lib/performance')(config)
};
};