azat-co / expressworks

Learn Express.js from the author of one of the best books on Express.js—Pro Express.js— with this workshop that will teach you basics of Express.js.
MIT License
715 stars 220 forks source link

Exercise 6 verify wrong #42

Closed mduleone closed 9 years ago

mduleone commented 9 years ago

I ran the verification of my solution twice, once thru sudo and once without. Both times, my solution seemed to work, but the verification step failed.

❯ expressworks verify index.js
Verifying "PARAM PAM PAM"...

ACTUAL                             EXPECTED
------                             --------
"663918365c1cf4aa90e1b997464837eeb216ff69" != "Cannot PUT /message/3f0a916de79d2a84e747342296f9ddb8"
# FAIL

Your solution to PARAM PAM PAM didn't match the expected output.
Try again!
❯ sudo expressworks verify index.js
Password:
Verifying "PARAM PAM PAM"...

ACTUAL                             EXPECTED
------                             --------
"467e7714bb0b77755e016a3737d2b8d961a3bd45" != "Cannot PUT /message/fd42373de17b40c04517a6e4c956778d"
# FAIL

Your solution to PARAM PAM PAM didn't match the expected output.
Try again!

My code (slightly different than the provided solution, but the same in spirit):

"use strict";

var express = require("express");
var crypto = require("crypto");

var app = express();
var port = process.argv[2];

app.put("/message/:id", function(req, res) {
    var id = req.params.id;
    var date = crypto.createHash("sha1").update(new Date().toDateString() + id).digest("hex");
    res.end(date);
});

app.listen(port);

I tried removing "use strict" as well as changing res.end(date) to res.send(date) to see if either was causing the verification script to fail to execute, but neither step resolved anything.

joker2600 commented 9 years ago

In any case all your permutations pass on Windows node v0.10.30. not sure what is up with verify not being unable to PUT.

mduleone commented 9 years ago

Every permutation I tried resulted in the same output as above. I wasn't sure if they were possibly causing the verification program to error after my code executed, but I wasn't able to "verify" after exercise 5 because of this problem. Just a thought... maybe the verification program is making the solution try to listen on the same port as the user code, and it's failing because of that?

Anyway, I compared my code against what the solution was doing and determined that the output I was getting was the correct output. Aside from that hiccup, and a couple grammar issues, this was an awesome tutorial! Thank you for putting it together!

jdharms commented 9 years ago

I ran into this today, and it seems that the problem in my situation was a hung node process still listening on the port the solution uses, 3001.

I imagine there was a problem with expressworks at some point that caused this, as I didn't pass 3001 to any of my invocations.

bbugh commented 9 years ago

I ran into this same problem, and killall node worked to fix it.

azat-co commented 9 years ago

58