Refactoring resource.js into db.js, so requring db.js doesn't prevent shutdown.