Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const handler = async (argv: ArgvType): Promise => {
// eslint-disable-next-line no-extra-parens, no-new-func
const filterColumn: ColumnFilterType = (argv.columnFilter ? new Function('tableName', 'columnName', 'columns', argv.columnFilter) : null: any);
// eslint-disable-next-line no-extra-parens, no-new-func
const mapTableName: TableNameMapperType = (argv.tableNameMapper ? new Function('tableName', 'columns', argv.tableNameMapper) : null: any);
const dataTypeMap: DataTypeMapType = argv.dataTypeMap ? JSON.parse(argv.dataTypeMap) : {};
const pool = await createPool(argv.databaseConnectionUri);
const columns = await getDatabaseColumns(pool);
const normalizedColumns = columns
.filter((column) => {
if (!filterColumn) {
return true;
}
return filterColumn(column.tableName, column.name, columns);
})
.map((column) => {
return {
...column,
isNullable: column.comment && column.comment.includes('POSTLOAD_NOTNULL') ? false : column.isNullable,
};