I'm new to Node and coming from a C# background one of the main things that I'm looking to figure out with Node is dependency injection. I understand that wire.js has that capability and I've read everything I can find on it and I've even downloaded the Html "Hello World" example. However, I'm still unable to get it to work properly.
Here's what I did to try to get it to work:
- I pulled the hello-wired.js and hello-wired-spec.js files into my Node project.
- I pulled in the wire folder from /js/wire from the sample app to /node-modules/wire in my Node app.
- I removed the line of code in hello-world.js in the constructor since I won't have an Html node and I made the constructor parameterless. I then replaced the line in sayHello to use console.log() since I won't have InnerHtml.
- I created a test action as
app.get('/testwired', function (req, res) {
require('wire!hello-wired-spec', function (spec) {
console.log(spec);
res.send(spec.sayHello("this is a test"));
});
});
The error that I'm getting is that it can't find the module wire!hello-wired-spec. I assume that means that I haven't configured wire.js to know where to get my spec, but I can't figure out how. I also don't know if I'm supposed to use a callback for this or not.
Any help is greatly appreciated.