icynet-auth-server/ormconfig.js

20 lines
678 B
JavaScript
Raw Normal View History

/* eslint-disable @typescript-eslint/no-var-requires */
const { join } = require('path');
const dotenv = require('dotenv');
const { readFileSync } = require('fs');
const toml = require('toml');
dotenv.config();
const CONFIG_ENV = process.env.NODE_ENV === 'production' ? 'prod' : 'dev';
const CONFIG_FILENAME = process.env.CONFIG || `config.${CONFIG_ENV}.toml`;
const CONFIG_PATH = join(process.cwd(), CONFIG_FILENAME);
2022-08-17 18:56:47 +00:00
// toml.parse returns an object that doesn't have the correct prototype,
// thus this JSON workaround is used.
2022-04-15 19:00:02 +00:00
const config = JSON.parse(
JSON.stringify(toml.parse(readFileSync(CONFIG_PATH, { encoding: 'utf-8' }))),
);
module.exports = config.database;