How to get the id in the middleware

How to get the id in the middleware??
ctx.state.user is undefined