@buka/nestjs-config
Version:
An easy to use nestjs config module
17 lines (16 loc) • 588 B
JavaScript
import { Logger } from '@nestjs/common';
import { readFile } from 'fs/promises';
import { fsExist } from '../utils/fs-exists.js';
import { parse } from 'smol-toml';
export function tomlFileLoader(filepath, encoding = 'utf-8') {
return async (options) => {
if (!await fsExist(filepath)) {
if (!options.suppressWarnings) {
Logger.warn(`env file not found: ${filepath}`, '@buka/nestjs-config');
}
return {};
}
const content = await readFile(filepath);
return parse(content.toString(encoding));
};
}