Why don't you assign "locals" to "ctx.state"?
origin:
`const state = Object.assign(locals, options, ctx.state || {})`

turn into:
`const state = Object.assign({}, options, ctx.state || {}, locals)`
Would it be better?