Site hosting on Assembla.com

RdbHost makes relational databases available to JavaScript apps in the browser. You do have to host the static app pages somewhere, and while you can store static pages (and other files) on RdbHost, other options can be attractive. Assembla will host pages, under your domain name even, with subversion as the deployment mechanism, and can be used to host the static part of your database-backed JavaScript application.

Here is an overview of how to setup a site on assembla.com, with RdbHost database hosting.

Create an Assembla Account:

This is very straightforward, following the prompts at assembla. You can create subversion and git accounts. Here we describe the subversion way.

Create a Directory in the Repository

Create a new directory in your repository for storing public files. You can name this directory as you like; this example uses a domain style name 'rdbhost.assembla.com'. Navigate to the new directory using the on-site repository browser.

assembla screenshot

Click the publish button and enter the chosen domain name, including subdomain as applicable.

assembla screenshot

We will assume sufficient familiarity with subversion to checkout the repository create the display directory, add new html content and commit all.

Setup Domains

To use the recommended JavaScript library for RdbHost, you need a site domain that you own. In your domain registrar's domain manager, create a principle domain (with or without subdomain) that points at www.assembla.me. The easiest way is to use a CNAME record. The domain you point at assembla.com should be the one you entered in the publish page above.

We have a tutorial on setting up domain pointers at GoDaddy, and the following is a screenshot of how one registrar handles zone editing, and RdbHost's domain configuration. This example also illustrates the recommended practice of creating a TXT record with your account number.

dns screenshot

After you publish the subversion directory and update your dns, you should be able to access your static index.html at that domain. I read that several hours may be required to propogate dns records, but have personally observed propogation times of approx 5 minutes.

Register Domain on RdbHost Account

Add the chosen domain to your RdbHost account configuration at the /mbr/domain page.

domain screenshot

Develop Your App

Develop your app in your 'example.assembla.com' folder, and periodically commit it to the assembla.com repository. You will be able to test it at the internet domain as well as on localhost.

We have a demonstration app, on a.rdbhost.com, called 'Three Faves'. This is the simplest database example app I could think of that might be fun. You enter 3 favorite things, and it looks for other people in the database that also entered any of those things, and shows you what else they entered. It is completely anonymous, and has a crowd-sourced bad-words filter.

three faves screenshot

As you develop your application, the JavaScript library will add items to the white-list, permitting anonymous users of your app to run those queries

The source for this app is in the rdbhost.github.com public github repository. It is one-file resource, with css and javascript all rolled in there, except for the rdbhost.jquery.js database library.

Database Roles

You also need to create the database roles that will query the database. Generally, for a JavaScript application, you would use the preauth or the auth role, perhaps in combination with the reader role. The roles are created from the role manager page. Privileges to the various tables and resources must be granted to the chosen roles, using SQL GRANT statements.

The 'Three Faves' app uses the preauth role, which is only permitted to run white-listed queries, so the database is protected against somebody trying to run arbitrary destructive queries as that role.

The creation of tables, views, indexes, etc, can be incorporated into your app, but the Rdbadmin utility is useful for creating initial tables and such. Use SQL GRANT to grant necessary privileges to the chosen roles.

role mgr screenshot

To summarize the main points:

  1. You can host static pages on www.assembla.com, under your own domain, and use RdbHost hosted databases from those static pages.
  2. Setup roles on RdbHost, and grant appropriate privileges to tables and other resources..
  3. Create tables and indexes using the RdbAdmin utility.
  4. Develop your application, clear the whitelist, repopulate with valid queries by testing every app feature, and you are done.