move resource loading into cores and api middleware into cores-hapi