Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const importEventStoreHandler = options => async (req, res) => {
const { storageAdapter } = req.resolve
try {
const { importFile } = options
const eventStream = storageAdapter.import()
const fsStream = fs.createReadStream(path.join(importFile))
await pipeline(fsStream, eventStream)
res.end('ok')
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
res.status(500)
res.end(String(error))
}
}
const exportEventStoreHandler = options => async (req, res) => {
const { storageAdapter } = req.resolve
try {
const { exportFile } = options
const eventStream = storageAdapter.export()
const fsStream = fs.createWriteStream(path.join(exportFile))
await pipeline(eventStream, fsStream)
res.end('ok')
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
res.status(500)
res.end(String(error))
}
}