-
-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathcube.js
More file actions
47 lines (42 loc) · 1.26 KB
/
cube.js
File metadata and controls
47 lines (42 loc) · 1.26 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
42
43
44
45
46
47
// https://cube.dev/docs/multitenancy-setup#multiple-db-instances-with-same-schema
// https://cube.dev/docs/product/configuration/advanced/multitenancy#multiple-db-instances-with-same-data-model
module.exports = {
extendContext: (req) => {
return {
securityContext: {
...req.securityContext,
}
}
},
contextToAppId: ({ securityContext }) =>
`CUBEJS_APP_${securityContext?.database || 'coopcycle'}`,
contextToOrchestratorId: ({ securityContext }) =>
`CUBEJS_APP_${securityContext?.database || 'coopcycle'}`,
driverFactory: ({ securityContext, dataSource }) => {
if (dataSource === 'clickhouse') {
return {
type: 'clickhouse',
host: 'clickhouse',
port: '8123',
database: process.env.CLICKHOUSE_DB,
username: process.env.CLICKHOUSE_USER,
password: process.env.CLICKHOUSE_PASSWORD,
ssl: false,
}
}
return {
type: 'postgres',
database: `${securityContext?.database || 'coopcycle'}`,
}
},
// https://cube.dev/docs/config#options-reference-scheduled-refresh-contexts
scheduledRefreshContexts: () => [
{
securityContext: {
database: 'coopcycle',
base_url: 'http://nginx',
instance: 'default'
},
},
],
};