add jsonrpc and make db functions use config instead of whole app