Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function(target: Function, key: string, index: number) {
let container: any;
try {
container = require("typedi/Container").Container;
} catch (err) {
throw new Error("OrmRepository cannot be used because typedi extension is not installed.");
}
container.registerParamHandler({
type: target,
index: index,
getValue: () => {
const connectionManager: ConnectionManager = container.get(ConnectionManager);
const connection = connectionManager.getConnection(connectionName);
return connection.getRepository(cls);
}
});
};
}