From 78e33e47b6e7373ab50b508ffa1943693dcbfaf2 Mon Sep 17 00:00:00 2001 From: tobil4sk <41230637+tobil4sk@users.noreply.github.com> Date: Sun, 14 Mar 2021 17:05:53 +0000 Subject: [PATCH] Fix deprecated class paths (haxe 4) abedev#32 js.Error -> js.lib.Error js.RegExp -> js.lib.RegExp Uses conditional compilation so should still work in older versions of haxe --- src/express/Error.hx | 2 +- src/express/Next.hx | 2 +- src/mw/BasicAuth.hx | 4 ++++ src/mw/BearerTokenAuth.hx | 4 ++++ src/mw/OnFinished.hx | 5 +++++ src/mw/Unless.hx | 4 ++++ src/mw/cors/Options.hx | 4 ++++ src/mw/expressbrute/Options.hx | 7 +++++++ 8 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/express/Error.hx b/src/express/Error.hx index aefa9a0..e9c35d5 100644 --- a/src/express/Error.hx +++ b/src/express/Error.hx @@ -1,6 +1,6 @@ package express; @:native("Error") -extern class Error extends js.Error { +extern class Error extends #if (haxe_ver>=4.0) js.lib.Error #else js.Error #end { public var status : Int; } diff --git a/src/express/Next.hx b/src/express/Next.hx index 89c10f8..22c4ba2 100644 --- a/src/express/Next.hx +++ b/src/express/Next.hx @@ -12,7 +12,7 @@ abstract Next(Dynamic) public inline function call() untyped this(); - public inline function error(err : js.Error) + public inline function error(err : #if (haxe_ver >= 4.0) js.lib.Error #else js.Error #end) untyped this(err); public inline function route() diff --git a/src/mw/BasicAuth.hx b/src/mw/BasicAuth.hx index 8267c8f..59a407a 100644 --- a/src/mw/BasicAuth.hx +++ b/src/mw/BasicAuth.hx @@ -5,7 +5,11 @@ import haxe.crypto.Base64; import express.Request; import express.Response; import express.Next; +#if (haxe_ver >= 4.0) +import js.lib.Error; +#else import js.Error; +#end import js.node.Buffer; using StringTools; diff --git a/src/mw/BearerTokenAuth.hx b/src/mw/BearerTokenAuth.hx index af8466f..b6b0a3b 100644 --- a/src/mw/BearerTokenAuth.hx +++ b/src/mw/BearerTokenAuth.hx @@ -3,7 +3,11 @@ package mw; import express.Request; import express.Response; import express.Next; +#if (haxe_ver >= 4.0) +import js.lib.Error; +#else import js.Error; +#end using StringTools; class BearerTokenAuth { diff --git a/src/mw/OnFinished.hx b/src/mw/OnFinished.hx index f45468a..48ba71c 100644 --- a/src/mw/OnFinished.hx +++ b/src/mw/OnFinished.hx @@ -2,7 +2,12 @@ package mw; import express.Request; import express.Response; + +#if (haxe_ver >= 4.0) +import js.lib.Error; +#else import js.Error; +#end @:jsRequire("on-finished") extern class OnFinished { diff --git a/src/mw/Unless.hx b/src/mw/Unless.hx index 05ccd54..6a809ed 100644 --- a/src/mw/Unless.hx +++ b/src/mw/Unless.hx @@ -3,7 +3,11 @@ package mw; import express.Request; import express.Middleware; import haxe.extern.EitherType; +#if (haxe_ver >= 4.0) +import js.lib.RegExp; +#else import js.RegExp; +#end import mw.jwt.*; @:jsRequire("express-unless") diff --git a/src/mw/cors/Options.hx b/src/mw/cors/Options.hx index f0d0a61..0b8acd0 100644 --- a/src/mw/cors/Options.hx +++ b/src/mw/cors/Options.hx @@ -2,7 +2,11 @@ package mw.cors; import express.Request; import haxe.extern.EitherType; +#if (haxe_ver >= 4.0) +import js.lib.Error; +#else import js.Error; +#end typedef Options = { ?origin : EitherType>, diff --git a/src/mw/expressbrute/Options.hx b/src/mw/expressbrute/Options.hx index cc33e29..57f25ab 100644 --- a/src/mw/expressbrute/Options.hx +++ b/src/mw/expressbrute/Options.hx @@ -39,8 +39,15 @@ Defines whether the remaining lifetime of a counter should be based on the time /* Gets called whenever an error occurs with the persistent store from which ExpressBrute cannot recover. It is passed an object containing the properties message (a description of the message), parent (the error raised by the session store), and [key, ip] or [req, res, next] depending on whether or the error occurs during reset or in the middleware itself. */ +#if (haxe_ver >= 4.0) + ?handleStoreError : EitherType< + ({ message : String, parent : js.lib.Error}, String, String) -> Void, + ({ message : String, parent : js.lib.Error}, Request, Response, Next) -> Void + > +#else ?handleStoreError : EitherType< { message : String, parent : js.Error} -> String -> String -> Void, { message : String, parent : js.Error} -> Request -> Response -> Next -> Void > +#end }