Doing 

```
if (!cachedDocs[type]) {
    return {'code': 500, 'msg': ...};
}

return _.keys(cachedDocs[type]);
```

would be much cleaner.