Skip to content

Commit

Permalink
Fix deprecated class paths (haxe 4) abedev#32
Browse files Browse the repository at this point in the history
js.Error -> js.lib.Error
js.RegExp -> js.lib.RegExp

Uses conditional compilation so should still work in older versions
of haxe
  • Loading branch information
tobil4sk committed Mar 14, 2021
1 parent 6e61196 commit 78e33e4
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/express/Error.hx
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion src/express/Next.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions src/mw/BasicAuth.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/mw/BearerTokenAuth.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/mw/OnFinished.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/mw/Unless.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions src/mw/cors/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bool, EitherType<String, OriginFunction>>,
Expand Down
7 changes: 7 additions & 0 deletions src/mw/expressbrute/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 78e33e4

Please sign in to comment.