move fileScope to separate module, update dependencies and devDependencies
[squeep-api-dingus] / lib / common.js
index f839e7a05cf16790779a75a2d6c15d19689d9f98..6b72129223cf88e8248706afa5679f853eb5d5ae 100644 (file)
@@ -5,29 +5,10 @@
  * Utility and miscellaneous functions.
  */
 
-const path = require('path');
-const crypto = require('crypto');
+const crypto = require('node:crypto');
 const uuid = require('uuid');
 const Enum = require('./enum');
-
-/**
- * @callback ScopeFn
- * @param {String} scope
- * @returns {String}
- */
-/**
- * Return a function which prefixes a provided scope with the most-
- * relevant part of the filename, for use in logging.
- * @param {String} filename
- * @returns {ScopeFn}
- */
-const fileScope = (filename) => {
-  let fScope = path.basename(filename, '.js');
-  if (fScope === 'index') {
-    fScope = path.basename(path.dirname(filename));
-  }
-  return (scope) => `${fScope}:${scope}`;
-};
+const { fileScope } = require('@squeep/log-helper');
 
 /**
  * Simple ETag from data.