From 684377e55cc239aa1f09ef9c65e1f768e8733fa5 Mon Sep 17 00:00:00 2001 From: piotrruss Date: Wed, 1 Jun 2022 18:07:07 +0100 Subject: log activity --- helpers/log.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 helpers/log.js (limited to 'helpers/log.js') diff --git a/helpers/log.js b/helpers/log.js new file mode 100644 index 0000000..5e570c2 --- /dev/null +++ b/helpers/log.js @@ -0,0 +1,13 @@ +import Log from 'models/Log' + +const log = async ({ email, action, callback, error }) => { + try { + await Log.create({ email, action, ...(error && {error: error?.message || '-'}) }) + } finally { + if (callback) { + return callback() + } + } +} + +export default log -- cgit v1.2.3