breaking CRUD middleware out of api core