Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getValue = () => {
const connectionManager = Container.get(ConnectionManager);
if (!connectionManager.has(connectionName))
throw new Error(`Cannot get connection "${connectionName}" from the connection manager. ` +
`Make sure you have created such connection. Also make sure you have called useContainer(Container) ` +
`in your application before you established a connection and importing any entity.`);
const connection = connectionManager.get(connectionName);
return connection.getCustomRepository(cls as any);
};
if (index !== undefined) {
Container.registerParamHandler({ type: target as Function, index: index, getValue: getValue });
} else {
Container.registerPropertyHandler({ target: target as Function /* todo: looks like typedi wrong type here */, key: propertyName, getValue: getValue });
}
};
}