forked from thomasstjerne/biom-io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
172 lines (152 loc) · 7.05 KB
/
config.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import * as url from 'url';
import fs from 'fs'
import base64 from 'base-64';
import {getYargs} from './util/index.js'
const gbifBaseUrl = {
prod: "https://api.gbif.org/v1/",
uat: "https://api.gbif-uat.org/v1/"
}
const gbifRegistryBaseUrl = {
prod: 'https://registry-api.gbif.org/',
uat: 'https://registry-api.gbif-uat.org/',
local: 'https://registry-api.gbif-uat.org/'
}
let gbifCredentials = {
uatUsername: null,
uatPassword: null,
uatInstallationKey: null,
uatPublishingOrganizationKey: null,
dataDirectory: "",
uatAuth: null,
organizationFilePath: null,
prodPublishingEnabled: false,
prodInstallationKey: null,
dataDirectory : null,
dwcPublicAccessUrl: null,
port: 9000
}
try {
console.log("Reading credentials from "+process.argv)
const yargs = getYargs()
const creds = fs.readFileSync(`${yargs.credentials || '../somefakepathfortesting/gbifCredentials.json'}`,
{ encoding: 'utf8', flag: 'r' });
gbifCredentials = JSON.parse(creds)
gbifCredentials.uatAuth = `Basic ${base64.encode(gbifCredentials.uatPublishingOrganizationKey + ":" + gbifCredentials.uatOrganizationToken)}`
gbifCredentials.organizationFilePath = yargs.organizationfile;
if(!!yargs?.port){
gbifCredentials.port = yargs?.port
}
/* gbifCredentials.prodPublishingEnabled = yargs.prodPublishingEnabled
*/ console.log(`Organization configuration file located at ${gbifCredentials.organizationFilePath} - this must be writable`)
} catch (error) {
console.log("No GBIF user credentials given")
}
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const env = process.env.NODE_ENV || 'local';
const config = {
local: {
expressPort: gbifCredentials?.port,
env: 'local',
prodPublishingEnabled: gbifCredentials?.prodPublishingEnabled,
nodeKey: gbifCredentials?.nodeKey,
termsLink: gbifCredentials?.termsLink,
installationAdmins: gbifCredentials?.installationAdmins,
installationContactEmail: gbifCredentials?.installationContactEmail,
dataStorage : gbifCredentials?.dataDirectory,
ebiOntologyService: 'https://www.ebi.ac.uk/ols/api/search',
dwcPublicAccessUrl: gbifCredentials?.dwcPublicAccessUrl,
rsyncDirectory: '[email protected]:~/public_html/edna',
gbifBaseUrl,
gbifRegistryBaseUrl,
blastService: "http://localhost:9001", //"http://blast.gbif-dev.org",
uatInstallationKey: gbifCredentials?.uatInstallationKey,
uatPublishingOrganizationKey: gbifCredentials?.uatPublishingOrganizationKey,
/* uatUsername: gbifCredentials?.uatUsername,
uatPassword: gbifCredentials?.uatPassword, */
uatAuth: gbifCredentials.uatAuth ,
prodInstallationKey: gbifCredentials?.prodInstallationKey,
gbifGbrdsBaseUrl: {
prod: 'https://gbrds.gbif-uat.org/',
uat: 'https://gbrds.gbif-uat.org/',
local: 'https://gbrds.gbif-uat.org/'
},
organizationFilePath: gbifCredentials.organizationFilePath,
title: gbifCredentials?.title,
description: gbifCredentials?.description,
frontendUrl: gbifCredentials?.frontendUrl,
backendProxyUrl: gbifCredentials?.backendProxyUrl
},
uat: {
expressPort: gbifCredentials?.port,
env: 'uat',
prodPublishingEnabled: gbifCredentials?.prodPublishingEnabled,
nodeKey: gbifCredentials.nodeKey,
termsLink: gbifCredentials?.termsLink,
installationAdmins: gbifCredentials?.installationAdmins,
installationContactEmail: gbifCredentials?.installationContactEmail,
dataStorage : gbifCredentials?.dataDirectory,
//dataStorage : "/mnt/auto/misc/hosted-datasets.gbif-uat.org/edna/" + gbifCredentials?.dataDirectory,
ebiOntologyService: "https://www.ebi.ac.uk/ols/api/search",
dwcPublicAccessUrl: gbifCredentials?.dwcPublicAccessUrl,
rsyncDirectory: '', // Only for dev env, will already be accessible via http on UAT
gbifBaseUrl,
gbifRegistryBaseUrl,
blastService: "http://blast.gbif-dev.org",
uatInstallationKey: gbifCredentials?.uatInstallationKey,
uatPublishingOrganizationKey: gbifCredentials?.uatPublishingOrganizationKey,
/* uatUsername: gbifCredentials?.uatUsername,
uatPassword: gbifCredentials?.uatPassword, */
uatAuth: gbifCredentials.uatAuth,
prodInstallationKey: gbifCredentials?.prodInstallationKey,
gbifGbrdsBaseUrl: {
prod: 'https://gbrds.gbif-uat.org/', // if the env is UAT, we do not publish to prod
uat: 'https://gbrds.gbif-uat.org/'
},
organizationFilePath: gbifCredentials.organizationFilePath,
title: gbifCredentials?.title,
description: gbifCredentials?.description,
frontendUrl: gbifCredentials?.frontendUrl,
backendProxyUrl: gbifCredentials?.backendProxyUrl
/* installationKey: "aec88852-acfa-4b12-af59-b4b50d6f07b2",
publishingOrganizationKey: "f7ecf12b-221d-4eea-806d-fb4b37face25",
gbifUsername: gbifCredentials?.username,
gbifPassword: gbifCredentials?.password */
},
prod: {
expressPort: gbifCredentials.port,
env: 'prod',
prodPublishingEnabled: gbifCredentials?.prodPublishingEnabled,
nodeKey: gbifCredentials.nodeKey,
termsLink: gbifCredentials?.termsLink,
installationAdmins: gbifCredentials?.installationAdmins,
installationContactEmail: gbifCredentials?.installationContactEmail,
dataStorage : gbifCredentials?.dataDirectory,
// dataStorage : "/mnt/auto/misc/hosted-datasets.gbif.org/edna/" + gbifCredentials?.dataDirectory,
ebiOntologyService: "https://www.ebi.ac.uk/ols/api/search",
dwcPublicAccessUrl: gbifCredentials?.dwcPublicAccessUrl,
rsyncDirectory: '', // Only for dev env, will already be accessible via http on UAT
gbifBaseUrl,
gbifRegistryBaseUrl,
blastService: "http://blast.gbif-dev.org",
uatInstallationKey: gbifCredentials?.uatInstallationKey,
uatPublishingOrganizationKey: gbifCredentials?.uatPublishingOrganizationKey,
/* uatUsername: gbifCredentials?.uatUsername,
uatPassword: gbifCredentials?.uatPassword, */
uatAuth: gbifCredentials.uatAuth,
prodInstallationKey: gbifCredentials?.prodInstallationKey,
gbifGbrdsBaseUrl: {
prod: 'https://gbrds.gbif.org/', // This can publish to prod
uat: 'https://gbrds.gbif-uat.org/'
},
organizationFilePath: gbifCredentials.organizationFilePath,
title: gbifCredentials?.title,
description: gbifCredentials?.description,
frontendUrl: gbifCredentials?.frontendUrl,
backendProxyUrl: gbifCredentials?.backendProxyUrl
/* installationKey: "aec88852-acfa-4b12-af59-b4b50d6f07b2",
publishingOrganizationKey: "f7ecf12b-221d-4eea-806d-fb4b37face25",
gbifUsername: gbifCredentials?.username,
gbifPassword: gbifCredentials?.password */
},
}
export default config[env]