Permalink
Browse files

Merge branch 'master' of github.com:dionjwa/nodejs_externs

Conflicts:
	js/node/Connect.hx
  • Loading branch information...
2 parents 561d025 + 472fe3a commit 0508001e7176de7c93c4843f54c3f4e395613e5b @dionjwa committed Apr 26, 2012
View
@@ -18,6 +18,7 @@ So far there are externs for:
socket-io
socket-io-client
mongodb
+ pubnub
Note that none of these externs are complete, in that the typedefs don't necessarily define every single variable and function. They define enough to be useful. Feel free to contribute additions and improvements.
View
@@ -0,0 +1,14 @@
+package js.browser;
+
+@:native("PUBNUB")
+extern
+class PubNub extends js.pubnub.PubNub {
+
+ public static function init(Setup : Dynamic) : PubNub;
+
+ private static function __init__() : Void untyped {
+ #if !noEmbedJSPubNub
+ haxe.macro.Tools.includeFile("js/browser/js/pubnub-3.1.min.js");
+ #end
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -44,9 +44,10 @@ typedef Connect = {
function createServer (a1 :Dynamic, ?a2 :Dynamic, ?a3 :Dynamic, ?a4 :Dynamic, ?a5 :Dynamic, ?a6 :Dynamic, ?a7 :Dynamic, ?a8 :Dynamic, ?a9 :Dynamic) :ConnectServer;
function cookieParser() :MiddleWare;
function bodyParser() :MiddleWare;
+ function logger() :MiddleWare;
function session(params :Dynamic) :Void;
function router(routes :Dynamic->Void) :Void;
- function errorHandler (options :Dynamic) :MiddleWare;
- //For 'static' use e.g. untyped __js__("connect.static(__dirname)") since Haxe has reserved the 'static' keyword
+ function Static (path :String, ?options :Dynamic) :MiddleWare;
+ function errorHandler (options :Dynamic) :MiddleWare;
}
View
@@ -16,15 +16,28 @@ typedef ExpressHttpServerReq = { > NodeHttpServerReq,
typedef ExpressHttpServerResp = { > NodeHttpServerResp,
function render(name : String, params : Dynamic) : Void;
function redirect(url : String) : Void;
+
+ @:overload(function () : Void {})
+ @:overload(function (value : String, code : Int) : Void {})
+ @:overload(function (type : String, value : Dynamic, code : Int) : Void {})
+ function send(value : Dynamic) : Void;
}
-
-
+
+
+typedef AddressAndPort = {
+ address : String,
+ port : Int
+}
+
typedef ExpressServer = {
function use (?middlewareMountPoint :Dynamic, middleware :Dynamic) :ConnectServer;
function get(path : String, f : ExpressHttpServerReq -> ExpressHttpServerResp -> Void) : Void;
+ function post(path : String, f : ExpressHttpServerReq -> ExpressHttpServerResp -> Void) : Void;
@:overload(function(port :Int, ready : Void -> Void):Void { } )
function listen (port :Int, ?address :String) :Void;
+
+ function address() : AddressAndPort;
}
extern
@@ -36,8 +49,8 @@ class Express {
public function bodyParser() :MiddleWare;
public function session(params :Dynamic) :Void;
public function router(routes :Dynamic->Void) :Void;
- public function Static (path :String, ?options :Dynamic) :MiddleWare;
- public function errorHandler (options :Dynamic) :MiddleWare;
+ public function Static (path :String, ?options :Dynamic) :MiddleWare;
+ public function errorHandler (options :Dynamic) :MiddleWare;
public function logger() : MiddleWare;
View
@@ -7,9 +7,6 @@ import js.Node;
*/
class JsHelper {
-
-// public static function requireAs<T>(name : String, cl : Class<T>) : T return
-// untyped js.Node.require(name)
inline public static function ifNull<T>(alt : T, v : T) : T return
v == null?alt:v
View
@@ -14,25 +14,57 @@ import js.node.MongoDbCollection;
* @author sledorze
*/
+/* To Implement (these are 'new's)
+class BsonSerializer {
+ new client.bson_serializer.Long(numberString)
+ new client.bson_serializer.ObjectID(hexString)
+ new client.bson_serializer.Timestamp() // the actual unique number is generated on insert.
+ new client.bson_serializer.DBRef(collectionName, id, dbName)
+ new client.bson_serializer.Binary(buffer) // takes a string or Buffer
+ new client.bson_serializer.Code(code, [context])
+}
+*/
+class MongoIdHelper {
+
+ inline public static function cleanId<Document>(data: Document) : Document {
+ untyped data._id = Std.string(data._id);
+ return data;
+ }
+
+ inline public static function cleanIds(datas: Array<Document>) : Array<Document> {
+ for (data in datas) {
+ untyped data._id = Std.string(data._id);
+ }
+ return datas;
+ }
+
+ inline public static function mongoIdStr(db : Db, x : String) : Dynamic return
+ untyped db.bson_serializer.ObjectID(x)
+
+ inline public static function mongoId<T>(db : Db, x : T) : Dynamic return
+ untyped db.bson_serializer.ObjectID(untyped x._id)
+}
@:native("Db")
extern
class Db {
+// public var bson_serializer : BsonSerializer;
+
public function open(callBack : Dynamic -> Db -> Void) : Void;
public function close() : Void;
public function admin(callBack : Error -> Admin -> Void) : Void;
- @:overload(function () : Cursor {})
- @:overload(function (callBack : Error -> Cursor -> Void) : Void {})
- public function collectionsInfo(collection_name : String, callBack : Error -> Cursor -> Void) : Void;
+ @:overload(function () : Cursor<Document> {})
+ @:overload(function (callBack : Error -> Cursor<Document> -> Void) : Void {})
+ public function collectionsInfo(collection_name : String, callBack : Error -> Cursor<Document> -> Void) : Void;
@:overload(function (callBack : Error -> Array<Document> -> Void) : Void {})
public function collectionNames(collection_name : String, callBack : Error -> Array<Document> -> Void) : Void;
- public function collection(collectionName : String, callBack : Error -> Collection -> Void) : Void;
- public function collections(callBack : Error -> Array<Collection> -> Void) : Void;
+ public function collection<Document>(collectionName : String, callBack : Error -> Collection<Document> -> Void) : Void;
+ public function collections(callBack : Error -> Array<Collection<Document>> -> Void) : Void;
@:overload(function (code : Dynamic, callBack : Error -> String -> Void) : Void {})
public function eval(code : Dynamic, parameters : Dynamic, callBack : Error -> String -> Void) : Void;
@@ -47,15 +79,15 @@ class Db {
public function logout (callBack : Error -> Dynamic -> Void) : Void;
- public function createCollection (collectionName : String, options : Dynamic, callBack : Error -> Collection -> Void) : Void;
+ public function createCollection<Document> (collectionName : String, options : Dynamic, callBack : Error -> Collection<Document> -> Void) : Void;
public function command (selector : String /*?*/, callBack : Error -> Dynamic -> Void /*?*/) : Void;
public function dropCollection (collectionName : String, callBack : Error -> Bool -> Void) : Void;
public function renameCollection (fromCollection : String, toCollection : String, callBack : Error -> Dynamic /*?*/ -> Void) : Void;
- public function lastError (callBack : Error -> Dynamic /*?*/ -> Void) : Void;
+ public function lastError (callBack : Error -> Array<Dynamic> /*?*/ -> Void) : Void;
public function error (callBack : Error -> Dynamic /*?*/ -> Void) : Void;
public function lastStatus(callBack : Error -> Dynamic -> Void) : Void;
Oops, something went wrong.

0 comments on commit 0508001

Please sign in to comment.