Last active
August 29, 2015 14:14
-
-
Save MadcapJake/21bd83dad31ebd76f29f to your computer and use it in GitHub Desktop.
Ceylon Express attempt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dynamic Express {} | |
Application requireExpressAndCallConstructor() { | |
dynamic { return require("express")(); } | |
} | |
dynamic Request {} | |
dynamic Response { | |
shared formal void send(String string); | |
} | |
dynamic Application { | |
shared formal void get(String path, | |
Anything(Request, Response)|Null|Anything(Request, Response)[] callbacks=null); | |
shared formal Server listen(Integer integer, Anything() callable); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dynamic Path { | |
} | |
dynamic Server { | |
shared formal dynamic address(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Run the module `my.express`." | |
shared void run() { | |
Application app = requireExpressAndCallConstructor(); | |
app.get("/", (Request req, Response res) { | |
return res.send("Hello world!"); | |
}); | |
Server server = app.listen(3000, () { | |
//dynamic host = server.address().address; | |
//dynamic port = server.address().port; | |
dynamic { | |
console.log( | |
"Example app listening..."// at http://%s:%s", | |
//host, | |
//port | |
); | |
} | |
return nothing; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've updated the code per your suggestions @chochos and I am now getting a new error that I don't understand 😕
I know it has to do with calling the return of
require
(i.e.,require("express")();
) but that is how the JavaScript is done. Here is the example given in the Express.js docs:And when I don't call the return (i.e.,
require("express");
), I get this: