Could you elaborate on what you mean by "frontend code can't enforce invariants" ?
That means that any validation that you do client-side you need to repeat server-side. Any business logic that you have client-side you also need to repeat server-side.