tiny-service
a tiny service library for generate service functiions
service usage
const {Service} =require('tiny-Service');
const roleService=Service(model);
the shape of roleService is
{
getModel:function(){ },
create:model.create,
remove:function(id){ },
update:function(id,record){ },
findById:function(id){ },
list:function(page=1,size=10,condition={}){ },
recent:function(page=1,size=10,condition={}){ },
}
to override the default method of service , just rewrite it:
roleService.list=function(page,size,condition){
};
middleware usage
const {Middleware}=require('tiny-service');
const middleware=Middleware(roleService);
const router=express.Router();
const middleware=Middleware(resourceService);
router.post('/create',bodyParser.json(),middleware.create);
router.post('/remove',bodyParser.json(),middleware.remove);
router.post('/update',bodyParser.json(),middleware.update);
router.post('/list',bodyParser.json(),middleware.list);
router.post('/recent',bodyParser.json(),middleware.recent);
module.exports=router;