Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.storage = createEsStorage({ databaseFile: ":memory:" });
} else {
this.storage = this.schema.storage;
}
if (this.schema.aggregateName) {
this.aggregateName = this.schema.aggregateName;
} else {
this.aggregateName = this.name;
}
const publishEvent = ctx => event => {
ctx.broker.broadcast(event.type, event);
};
this.eventStore = createEventStore({
storage: this.storage,
publishEvent: publishEvent(this),
});
if (this.settings.aggregate) {
this.aggregate = this.settings.aggregate;
delete this.settings.aggregate;
this.commandHandler = commandHandler({
eventStore: this.eventStore,
aggregates: [this.aggregate],
// snapshotAdapter
});
this.metadata.aggregate = true;
this.metadata.commands = Object.keys(this.aggregate.commands).map(
name => name
);
case 'mongo':
adapter = createMongoDBAdapter({
url: process.env.MONGO_URL
})
break
default:
throw new Error(
`Incorrect process.env.ADAPTER = ${process.env.ADAPTER}`
)
}
const storage = createStorage({
pathToFile: path.join(__dirname, 'event-storage.db')
})
const eventStore = createEventStore({ storage })
const connectorName = 'default-adapter'
const readModelName = 'default-read-model'
const query = createQuery({
eventStore,
viewModels: [],
readModelConnectors: {
[connectorName]: adapter
},
readModels: [
{
name: readModelName,
connectorName,
projection,
resolvers
}