Lotsa typescript bullshit

This commit is contained in:
mrfry 2020-11-24 10:47:04 +01:00
parent b7ac485689
commit b927988017
65 changed files with 801 additions and 8447 deletions

View file

@ -1,6 +1,11 @@
const logger = require('../utils/logger.js')
import logger from '../utils/logger'
module.exports = function(options) {
interface Options {
loggableKeywords: Array<string>
loggableModules: Array<string>
}
export default function(options: Options): any {
const loggableKeywords = options ? options.loggableKeywords : undefined
const loggableModules = options ? options.loggableModules : undefined
@ -24,13 +29,13 @@ module.exports = function(options) {
// fixme: regexp includes checking
const hasLoggableKeyword =
loggableKeywords &&
loggableKeywords.some((x) => {
return req.url.includes(x)
loggableKeywords.some((keyword) => {
return req.url.includes(keyword)
})
const hasLoggableModule =
loggableModules &&
loggableModules.some((x) => {
return hostname.includes(x)
loggableModules.some((keyword) => {
return hostname.includes(keyword)
})
const toLog = hasLoggableModule || hasLoggableKeyword