It's worth it to expand `res` to `resource` here. `res` is ambiguous. Since you call the argument `key`, `resourceFromKey` might be a better name altogether to make this code more readable?