This repository has been archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added includemod example for javascript
accordingly to "http://vertx.io/mods_manual.html#including-the-resources-of-modules"
- Loading branch information
Alwin Karabiowski
committed
Sep 10, 2013
1 parent
8d01f53
commit 0b08670
Showing
5 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/bar.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var sayHello = function(name) { | ||
return "Hello " + name; | ||
}; | ||
|
||
module.exports.sayHello = sayHello; |
3 changes: 3 additions & 0 deletions
3
src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/mod.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/test.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//Test if requiring bar lib works locally | ||
var bar = require("./bar.js"); | ||
|
||
if (bar.sayHello("User") == "Hello User") { | ||
console.log("requiring bar.js works"); | ||
} else { | ||
console.log("requiring bar.js didn't work"); | ||
} |
4 changes: 4 additions & 0 deletions
4
src/modules/javascript/includemod/mods/com.acme~module1~v1.0/mod.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"includes": "com.acme~common-stuff~v1.0", | ||
"main": "run_module_1.js" | ||
} |
15 changes: 15 additions & 0 deletions
15
src/modules/javascript/includemod/mods/com.acme~module1~v1.0/run_module_1.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var vertx = require('vertx'); | ||
var console = require('vertx/console'); | ||
var bar = require('bar.js'); | ||
|
||
var server = vertx.createHttpServer(); | ||
|
||
server.requestHandler(function(request) { | ||
request.response.end(bar.sayHello("User")); | ||
}); | ||
|
||
server.listen(8181, 'localhost', function(err) { | ||
if (!err) { | ||
console.log("Server listening on 8181"); | ||
} | ||
}); |