Custom keycloak middleware

Is there any way to add custom logic in the keycloak middleware?? This is on nodejs