Update index.js

Added logout and checks for operations on resources