|
1 | 1 | const { ApiConfig, getDataset, getDatasetStorageDriver, getCollection } = require('./dist') |
2 | 2 |
|
3 | 3 | function requiredEnv(name) { |
4 | | - const value = process.env[name] |
5 | | - if (!value) { |
6 | | - throw new Error(`Missing required environment variable: ${name}`) |
7 | | - } |
8 | | - return value |
| 4 | + const value = process.env[name] |
| 5 | + if (!value) { |
| 6 | + throw new Error(`Missing required environment variable: ${name}`) |
| 7 | + } |
| 8 | + return value |
9 | 9 | } |
10 | 10 |
|
11 | 11 | async function main() { |
12 | | - const DATAVERSE_API_URL = "http://localhost:8080/api" |
13 | | - const DATAVERSE_API_KEY = "e79d640d-0cc1-465d-b5a1-1bc134d562e8" |
14 | | - const DATASET_ID = "reviews" |
15 | | - const DATASET_VERSION = process.env.DATASET_VERSION || 'latest' |
| 12 | + const DATAVERSE_API_URL = 'http://localhost:8080/api' |
| 13 | + const DATAVERSE_API_KEY = 'e79d640d-0cc1-465d-b5a1-1bc134d562e8' |
| 14 | + const DATASET_ID = 'reviews' |
| 15 | + const DATASET_VERSION = process.env.DATASET_VERSION || 'latest' |
16 | 16 |
|
17 | | - ApiConfig.init("http://localhost:8080/api", ApiConfig.API_KEY, "e79d640d-0cc1-465d-b5a1-1bc134d562e8"); |
| 17 | + ApiConfig.init( |
| 18 | + 'http://localhost:8080/api', |
| 19 | + ApiConfig.API_KEY, |
| 20 | + 'e79d640d-0cc1-465d-b5a1-1bc134d562e8' |
| 21 | + ) |
18 | 22 |
|
19 | | - |
20 | | - getCollection.execute("reviews") |
21 | | - .then(collection => { |
22 | | - console.log('Collection allowed dataset types:', collection.allowedDatasetTypes); |
23 | | - console.log('Collection:', collection); |
24 | | - }) |
25 | | - .catch(error => { |
26 | | - console.error('Error fetching collection:', { |
27 | | - name: error?.name, |
28 | | - message: error?.message, |
29 | | - cause: error?.cause, |
30 | | - stack: error?.stack, |
31 | | - }); |
32 | | - }); |
| 23 | + getCollection |
| 24 | + .execute('reviews') |
| 25 | + .then((collection) => { |
| 26 | + console.log('Collection allowed dataset types:', collection.allowedDatasetTypes) |
| 27 | + console.log('Collection:', collection) |
| 28 | + }) |
| 29 | + .catch((error) => { |
| 30 | + console.error('Error fetching collection:', { |
| 31 | + name: error?.name, |
| 32 | + message: error?.message, |
| 33 | + cause: error?.cause, |
| 34 | + stack: error?.stack |
| 35 | + }) |
| 36 | + }) |
33 | 37 | } |
34 | 38 |
|
35 | 39 | main().catch((error) => { |
36 | | - console.error('Execution failed:') |
37 | | - console.error(error?.message || error) |
38 | | - process.exit(1) |
| 40 | + console.error('Execution failed:') |
| 41 | + console.error(error?.message || error) |
| 42 | + process.exit(1) |
39 | 43 | }) |
0 commit comments