-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed files and testing for the workshop
- Loading branch information
Diego Lafuente
committed
Jan 16, 2015
1 parent
1647e8b
commit 6c0d4b3
Showing
9 changed files
with
85 additions
and
24 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,22 +1,23 @@ | ||
"use strict"; | ||
|
||
var express = require("express"); | ||
var fs = require("fs"); | ||
|
||
var server = express(); | ||
|
||
server.get("/", serve); | ||
|
||
server.listen(9615, function(error, result) { | ||
server.listen(9615, function(error) { | ||
if (error) { | ||
console.log("Error when trying to listen in port 9615."); | ||
return; | ||
} | ||
console.log("Listening on port 9615"); | ||
}) | ||
}); | ||
|
||
function serve(request, response) { | ||
console.log("Reading index.html and serving it") | ||
var index = fs.readFileSync('index.html'); | ||
response.writeHead(200, {'Content-Type': 'html'}); | ||
console.log("Reading index.html and serving it"); | ||
var index = fs.readFileSync("index.html"); | ||
response.writeHead(200, {"Content-Type": "html"}); | ||
response.end(index); | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
"use strict"; | ||
|
||
var net = require('net'); | ||
var net = require("net"); | ||
|
||
var server = net.Server(); | ||
|
||
|
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,25 @@ | ||
{ | ||
"name": "node-workshop", | ||
"description": "A set of code snippets developed for a MallorcaJS workshop", | ||
"version": "0.0.1", | ||
"author": { | ||
"name": "Diego Lafuente", | ||
"email": "[email protected]" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DiegoTUI/node-workshop.git" | ||
}, | ||
"dependencies": { | ||
"express": "4.11.x", | ||
"testing":"0.1.x", | ||
"grunt": "0.4.x", | ||
"grunt-contrib-jshint": "0.10.x" | ||
}, | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
} | ||
} |
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,24 @@ | ||
"use strict"; | ||
|
||
// requires | ||
var testing = require("testing"); | ||
|
||
/** | ||
* Run all module tests. | ||
*/ | ||
exports.test = function(callback) { | ||
var tests = {}; | ||
var files = {pad: "./unit-tests/pad.js"}; | ||
|
||
for(var key in files) { | ||
tests[key] = require(files[key]).test; | ||
} | ||
|
||
testing.run(tests, callback); | ||
}; | ||
|
||
// run tests if invoked directly | ||
if (__filename == process.argv[1]) | ||
{ | ||
exports.test(testing.show); | ||
} |
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 @@ | ||
"use strict"; | ||
|
||
var pad = require("./pad.js").pad; | ||
|
||
console.log("3 padded: " + pad(3,3)); |
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