Code snippet to use as a foundation for your killer backendservice
Here comes a basic template for a BackendService. It contains "handlers" (well switch-es and case-es) for every known system event.
import { ApplicationBackendServiceBase, BackendServiceEventTypes } from'@dms';export*from'@dms';export*from'@dms-bo';exportdefaultclassBackendServiceextendsApplicationBackendServiceBase {publicasyncprocessEvent( event: { eventName:string; eventArguments: { appArea:string; appCode:string; userName:string; request: { httpMethod:string; restCommand:string; headers:any; body:any; queryStringParameters:any; }; }; }):Promise<any> {switch (event.eventName) {case"system:schedule:tick": {//here comes the interval based processing//no need to return anything//throw error if something is not as expectedbreak; }case"system:api:inbound": { //here comes the REST API event processing//return some result herebreak; }case"system:packet:push": { //here comes the packet push processing//do not return anything, just throw error if you hit something wrongbreak; }default: thrownewError("unknown system event"); } }}
You don't need to respond or process every system event type, so you may skip the case-es for system event types of no interest.