-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding request header x-api-version to have package.json version
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import _ from 'lodash'; | ||
import yaml from 'js-yaml'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import { logger } from '../config/logger.cjs'; | ||
|
||
export const fileLoader = _.memoize((filepath) => { | ||
logger.debug(`Reading file at ${filepath}`); | ||
|
||
const file = path.resolve(filepath); | ||
|
||
try { | ||
return yaml.load(fs.readFileSync(file, 'utf8')); | ||
} catch (e) { | ||
logger.error(`File not found at ${file}`, e); | ||
} | ||
}); |