Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAQ: invoke app.use(seneca.export("web")); throw err (app.use() requires a middleware) #326

Open
fandong90 opened this issue Apr 9, 2018 · 1 comment

Comments

@fandong90
Copy link

var seneca=require("seneca")();
seneca.add('role:api,cmd:bazinga',function (msg,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"));
app.listen(3000,function () {
console.log("visit port"+process.env.PORT);
})

------expection:

throw new TypeError('app.use() requires a middleware function')
ypeError: app.use() requires a middleware function
at Function.use (/Users/fandong/Desktop/vsCode/microService/node_modules/express/lib/application.js:210:11)
at Object. (/Users/fandong/Desktop/vsCode/microService/SenecaDemo/webPattern.js:14:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3


I am studying Node.js MicroServices .Can you help me .

@tswaters
Copy link
Member

I'd take a look at the usage docs for seneca-web-adapter-express

https://github.com/senecajs/seneca-web-adapter-express

Looks like what you have is from a pretty old version of seneca-web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants