node.js - Unable to run seneca for rest microservices -
i having following code in executable js after necessary imports.
seneca.ready(function(err){ seneca.act('role:web', {use:{ prefix: '/products', pin: {area:'product', action:'*'}, map: { list:{get:true} } }}) var express = require('express'); var app = express(); app.use(require('body-parser').json()); app.use( seneca.export('web') ); app.listen(8082);
});
i getting following error while trying run example:
seneca fatal error
message: seneca: export web has not been defined plugin.
code: export_not_found
details: { key: 'web' }
thanks, sumit
i beginner, hope snippet useful:
var seneca = require('seneca')() var web = require("seneca-web"); var express = require('express'); var app = express(); var config = { routes : [ { prefix : '/products', pin : { area : 'product', action : '*' }, map : { list : { : true } } } ], adapter : require('seneca-web-adapter-express'), context : app }; seneca.use(web, config); seneca.add({ role: "web", area : "product", action : "list" }, function(req, done) { done(null,{result: "my list of products"}); }); seneca.ready(function(err) { app.use(require('body-parser').json()); app.use(seneca.export('web/context')); app.listen(8082); seneca.act('role:web,area:product,action:list',console.log); });
seneca web has encountered changes , should use adapter express. can see examples here on seneca-web github page
Comments
Post a Comment