I'm a noob at seneca and I'm just trying to run sample codes from Developing Microservices with Node js, and it says:
var seneca = require('seneca')();
seneca.add('role:api,cmd:bazinga',function(args,done){
done(null,{bar:"Bazinga!"});
});
seneca.act('role:web',{use:{
prefix: '/my-api',
pin: {role:'api',cmd:'*'},
map:{
bazinga: {GET: true}
}
}})
var express = require('express');
var app = express();
app.use( seneca.export('web') ); // <<<<<< this line might be the cause
app.listen(3000);
but Im getting an error that says:
TypeError: app.use() requires middleware functions at EventEmitter.use (/home/oem/node_modules/express/lib/application.js:209:11) at Object. (/home/oem/Documents/seneca/app.js:7:8) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:974:3
Also I tried to run another sample code copied from the web, I'm sorry I just can find the link. But I just copied, pasted and tried to run and I got the same error. I'm thinking this is more of a setup issue?
edit
I'm still trying to play with this. The way I understand this is that on app.use line, basically I'm just calling the seneca-web module. so what I did was
app.use(require('seneca-web'))
instead of
app.use( seneca.export('web') )
then I ran node app.js
, it ran the script with no error in the command.
but when tried to access the module from a browser, then I got the error saying util is not found and is pointing to the seneca web file, which actually is from a call from seneca. now I'm not sure what to do now
I tried to lower the version of the node version that I have to 4.0 from 6.0, but still got the same error