added / fixed some types

This commit is contained in:
mrfry 2022-03-14 19:35:42 +01:00
parent 5f12284bb8
commit bc5c293539
41 changed files with 4378 additions and 8304 deletions

View file

@ -1,4 +1,6 @@
import logger from '../utils/logger'
import type { Response, NextFunction } from 'express'
import type { Request } from '../types/basicTypes'
interface Options {
loggableKeywords: Array<string>
@ -13,7 +15,7 @@ export default function (options: Options): any {
const exceptions = options.exceptions || []
const excludeFromStats = options.excludeFromStats || []
return function (req, res, next) {
return function (req: Request, res: Response, next: NextFunction) {
res.on('finish', function () {
// TODO: test this
const isException = exceptions.some((ex) => {
@ -24,7 +26,6 @@ export default function (options: Options): any {
return
}
const ip = req.headers['cf-connecting-ip'] || req.connection.remoteAddress
let hostname = 'NOHOST'
if (req.hostname) {
hostname = req.hostname.replace('www.', '').split('.')[0]
@ -59,7 +60,6 @@ export default function (options: Options): any {
if (res.statusCode !== 404 && shouldLogStat) {
logger.LogStat(
req.url,
ip,
hostname,
req.session && req.session.user ? req.session.user.id : 'NOUSER'
)