refactor(core): fix for no-uncaught-json-parse warnings

This commit is contained in:
Michael Kret
2022-10-21 21:52:43 +03:00
committed by GitHub
parent ca9eca9ae9
commit 1d57b10942
36 changed files with 150 additions and 93 deletions

View File

@@ -1,3 +1,4 @@
import { jsonParse } from 'n8n-workflow';
import { ValueTransformer } from 'typeorm';
import config from '../../../config';
@@ -16,8 +17,7 @@ export const lowerCaser = {
*/
export const objectRetriever: ValueTransformer = {
to: (value: object): object => value,
from: (value: string | object): object =>
typeof value === 'string' ? (JSON.parse(value) as object) : value,
from: (value: string | object): object => (typeof value === 'string' ? jsonParse(value) : value),
};
/**
@@ -27,8 +27,7 @@ export const objectRetriever: ValueTransformer = {
const jsonColumn: ValueTransformer = {
to: (value: object): string | object =>
config.getEnv('database.type') === 'sqlite' ? JSON.stringify(value) : value,
from: (value: string | object): object =>
typeof value === 'string' ? (JSON.parse(value) as object) : value,
from: (value: string | object): object => (typeof value === 'string' ? jsonParse(value) : value),
};
export const sqlite = { jsonColumn };