The Service class must be used as the base of any decorated service. Most options can be added either by defining them in the class itself or by adding them to the decorator options.
@service()
classExampleextendsService{
version =1;
settings ={};
metadata ={
test:"This is a test"
};
mixins =[];
}
classBaseextendsService{}
@service({
name:"Tester",
version:1,
settings:{},
metadata:{
test:"This is a test"
},
mixins:[]
})
classExample2extendsBase{
}
Parameters
Param decorators for Fastest Validator are provided and creating custom param decorators is easy.
Actions can have options set in the same format as the ServiceSchema. The handler can be defined with the parameters of the context or you can set the parameters in the action options and use a Context as the only parameter to the handler.
@service()
classExampleextendsService{
@action({
name:"getHelp",
cache:true,
metrics:{params:false,meta:true}
})
publichelp(@string()text:string){}
}
@service()
classExample2extendsService{
@action({
name:"getHelp",
cache:true,
metrics:{params:false,meta:true},
params:{
text:"string"
}
})
publichelp(ctx:Context){}
}
Events
Event handlers are added easily with options available to make it more flexible.