gristlabs_grist-core/ormconfig.js
Paul Fitzpatrick 5ef889addd (core) move home server into core
Summary: This moves enough server material into core to run a home server.  The data engine is not yet incorporated (though in manual testing it works when ported).

Test Plan: existing tests pass

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2552
2020-07-21 20:39:10 -04:00

50 lines
1.8 KiB
JavaScript

// 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)
}
};
}