forked from gristlabs/grist-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.js
49 lines (46 loc) · 1.85 KB
/
ormconfig.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
// Cache configuration for typeorm does not seem available via ormconfig.env, so
// we use ormconfig.js style.
const {codeRoot} = require('app/server/lib/places');
module.exports = {
"name": process.env.TYPEORM_NAME || "default",
"type": process.env.TYPEORM_TYPE || "sqlite", // officially, TYPEORM_CONNECTION -
// but if we use that, this file will never
// be read, and we can't configure
// caching otherwise.
"database": process.env.TYPEORM_DATABASE || "landing.db",
"username": process.env.TYPEORM_USERNAME || null,
"password": process.env.TYPEORM_PASSWORD || null,
"host": process.env.TYPEORM_HOST || null,
"port": process.env.TYPEORM_PORT || null,
"synchronize": false,
"migrationsRun": false,
"logging": process.env.TYPEORM_LOGGING === "true",
"entities": [
`${codeRoot}/app/gen-server/entity/*.js`
],
"migrations": [
`${codeRoot}/app/gen-server/migration/*.js` // migration files don't actually get packaged.
],
"subscribers": [
`${codeRoot}/app/gen-server/subscriber/*.js`
],
"cli": {
"entitiesDir": `${codeRoot}/app/gen-server/entity`,
"migrationsDir": `${codeRoot}/app/gen-server/migration`,
"subscribersDir": `${codeRoot}/app/gen-server/subscriber`
}
};
// If we have a redis server available, tell typeorm. Then any queries built with
// .cache() called on them will be cached via redis.
// We use a separate environment variable for the moment so that we don't have to
// enable this until we really need it.
if (process.env.TYPEORM_REDIS_URL) {
const url = require('url').parse(process.env.TYPEORM_REDIS_URL);
module.exports.cache = {
type: "redis",
options: {
host: url.hostname,
port: parseInt(url.port || "6379", 10)
}
};
}