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 9f9dd9a..64e8f34 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 }