Handler for cScriptDbCom requests

The VBA API generates REST API requests from your VBA function calls, and needs a Google Apps Script handler to service those requests by communicating with the required scriptDB instance.

You can have multiple handlers, chosen by the URL you used when initializing the VBA cScriptDBcom instance. In this getting started section, I have a handler that is only going to authorize READONLY type requests.

A handler needs a reference to the GAS LIbrary, cScriptDbCom. Add reference to resource ML7nE0jnmV4tCqTYKNkIykai_d-phDA33 to your project when you come to build your own.

Typical Handler code

It is unlikely you will need to make much changes to this code when you come to write your own handler, aside from to adjust the scriptDB dispatcher library reference, and to adjust the type of access based on the user keys. In this case I'm only allowing read operations, regardless of who is accessing. 

Note that a different handler may well access the same scriptDB via the dispatcher, for example, for an administrator to update it. This is why I recommend separating the Request Handler from the scriptDB dispatcher. 

Private handler

In my architecture, I make the url of the readonly handler available publicly, but restrict access to the fully function handler by Google oAuth2 authentication. If necessary I could further refine this access by examining the user keys. Here's my fully functional handler. The only difference is I don't restrict access with 
var whatsAllowed = ['query','count','getbyid'];

You can get me on Google plus, Twitter or this forum, and compare this topic with parse.com - nosql database for VBA and parse.com - noSQL database for GAS so you can see more about choosing about which noSQL database to use.

For help and more information join our forumfollow the blogfollow me on twitter

Comments