aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/log.js
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2022-06-01 18:07:07 +0100
committerGravatar piotrruss <mail@pruss.it> 2022-06-01 18:07:07 +0100
commit684377e55cc239aa1f09ef9c65e1f768e8733fa5 (patch)
tree4751ffdfb161e11a77969b915db8cd1e9cf6bc66 /helpers/log.js
parent308d07785f811ff470d0e90b11680926a823027b (diff)
downloadmy_apps-684377e55cc239aa1f09ef9c65e1f768e8733fa5.tar.gz
my_apps-684377e55cc239aa1f09ef9c65e1f768e8733fa5.tar.bz2
my_apps-684377e55cc239aa1f09ef9c65e1f768e8733fa5.zip
log activity
Diffstat (limited to 'helpers/log.js')
-rw-r--r--helpers/log.js13
1 files changed, 13 insertions, 0 deletions
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