Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return (object: any, propertyName: string, index?: number): any => {
const eventDispatcher = new EventDispatcherClass();
Container.registerHandler({ object, propertyName, index, value: () => eventDispatcher });
};
}
return function(object: Object|Function, propertyName: string, index?: number) {
Container.registerHandler({ object, index, propertyName, value: () => {
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.`);
return connectionManager.get(connectionName);
}});
};
}
if (!propertyType) {
throw new PropertyTypeMissingError(object, propertyName);
}
repositoryType = propertyType;
}
switch (repositoryType) {
case Repository:
case MongoRepository:
case TreeRepository:
if (!entityType) {
throw new EntityTypeMissingError(object, propertyName, index);
}
}
Container.registerHandler({
index,
object,
propertyName,
value: () => getRepository(connectionName, repositoryType, entityType!),
});
};
}
return (object: any, propertyName: string, index?: number): void => {
const eventDispatcher = new EventDispatcherClass();
Container.registerHandler({ object, propertyName, index, value: () => eventDispatcher });
};
}
return (object, propertyKey, index): any => {
const logger = new WinstonLogger(scope);
const propertyName = propertyKey ? propertyKey.toString() : '';
Container.registerHandler({ object, propertyName, index, value: () => logger });
};
}
return function(object: Object|Function, propertyName: string, index?: number) {
Container.registerHandler({ object, index, propertyName, value: () => {
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);
const entityManager = connection.manager;
if (!entityManager)
throw new Error(`Entity manager was not found on "${connectionName}" connection. ` +
`Make sure you correctly setup connection and container usage.`);
return entityManager;
}});
};
}