@kasko/fe-webapp-utils-lib
Advanced tools
Comparing version 1.0.3 to 1.1.0
# Changelog | ||
## [v1.1.0](https://github.com/kasko/fe-webapp-utils-lib/compare/v1.0.3...v1.1.0) (2022-06-10) | ||
## Feature | ||
- `dev` - Fixes case sensitivity in contents loader; | ||
- `dev` - Removes need for pointing path to files to load; | ||
## [v1.0.3](https://github.com/kasko/fe-webapp-utils-lib/compare/v1.0.2...v1.0.3) (2022-06-03) | ||
@@ -4,0 +9,0 @@ ## Other |
declare function requireTypescript(entry: string, cacheName: string): Promise<Record<string, any>>; | ||
declare function buildResponse<T extends Record<string, any> = Record<string, any>>(entryPath: string, responsePath: string, id: string, language?: string): Promise<T>; | ||
declare function buildResponse<T extends Record<string, any> = Record<string, any>>(entryJSON: Record<string, any>, responseJSON: Record<string, any>, id: string, language?: string): Promise<T>; | ||
export { requireTypescript, buildResponse, }; |
@@ -84,5 +84,3 @@ var __defProp = Object.defineProperty; | ||
} | ||
async function buildResponse(entryPath, responsePath, id, language) { | ||
const timeName = `${id} endpoint built`; | ||
console.time(timeName); | ||
async function buildResponse(entryJSON, responseJSON, id, language) { | ||
const { | ||
@@ -92,8 +90,8 @@ fieldDefinition, | ||
contents | ||
} = await requireTypescript(entryPath, id); | ||
const responseJSON = require(responsePath); | ||
} = entryJSON; | ||
const responseClone = JSON.parse(JSON.stringify(responseJSON)); | ||
const lang = language || "en"; | ||
if (contents[lang]) { | ||
responseClone.content = (0, import_csv.csvToObject)(contents[lang]); | ||
const content = Object.entries(contents).find(([key]) => key.toLocaleLowerCase() === lang.toLocaleLowerCase()); | ||
if (content) { | ||
responseClone.content = (0, import_csv.csvToObject)(content[1]); | ||
} else { | ||
@@ -100,0 +98,0 @@ console.error(`!!! Language "${lang}" for "${id}" is not defined.`); |
{ | ||
"name": "@kasko/fe-webapp-utils-lib", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
22781
7
551