AppengineJS: JavaScript Comes to GAE

DZone 's Guide to

AppengineJS: JavaScript Comes to GAE

· Cloud Zone ·
Free Resource
Although there's no JavaScript SDK made by Google for the App Engine platform, a new port of the GAE Python SDK to JavaScript called AppengineJS facilitates the construction of apps for GAE that are written in the language that all web developers are familiar with.  The port uses Rhino (the JVM implementation of JavaScript) on top of App Engine Java, but the API is based on App Engine Python because it's a scripting language like JS.

In a blog this week, George Moschovitis, one of the project developers, said that his project has recently garnered an intense amount of interest, and he had a couple of answers to readers' comments.  He said that if you already know Python or Java, you should stick with those SDKs, which are supported by Google.  The App Engine Python documentation should work effectively for the JavaScript SDK.  

The AppengineJS documentation explains that they use JavaScript coding conventions:

Python names like 'thisisa_name' are converted to JavaScript names like 'thisIsAName'. Moreover all delete() functions are renamed to .remove() functions to avoid collisions with the delete keyword (a DELETE() alias is also provided but it's uses is not recommended and may be deprecated in the future).

For the GAE Datastore, the the Python ext/db api is supported, but the API has been slightly modified to be more compatible with JavaScript:
var db = require("google/appengine/ext/db");

var Category = db.Model("Category", {
label: new db.StringProperty(),
category: new db.ReferenceProperty({referenceClass: Category})

var c = new Category({keyName: "news", label: News"});
var key = ...
var c1 = Category.get(key);
var c2 = Category.getByKeyName("news");
var categories = Category.all().fetch(3);
var comments = Comment.all().ancestor(article).order("-created").withCursor(cursor).fetch(10);

Here's a sample of the AppengineJS documentation pertaining to the Blobstore:

var blobstore = require("google/appengine/api/blobstore");

exports.GET = function(env) {
return {data: {
uploadURL: blobstore.createUploadUrl("/test")

<form action="{uploadURL}" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<button type="submit">Upload</button>
var blobstore = require("google/appengine/api/blobstore");

exports.GET = function(env) {
return {data: {
uploadURL: blobstore.createUploadUrl("/save")
var blobstore = require("google/appengine/api/blobstore");

exports.POST = function(env) {
var blobs = blobstore.getUploadedBlobs(env);

return {
status : 303,
headers : {
"Location": "/serve?key=" + blobs.file.toString()
var blobstore = require("google/appengine/api/blobstore");

exports.GET = function(env) {
var params = new Request(env).GET();
return blobstore.serve(params.key, env);

Also covered in the AppengineJS docs are URL Fetches, Images, Email, Memcache, Users, Task Queue, XMPP, Forms, Quota, and OAuth.  The library is still under development, but it's definitely usable right now.  Here is the breakdown of the level of Python API conversions:

    •    google/appengine/api/ memcache: 90% (usable)
    •    google/appengine/api/ urlfetch: 80% (usable)
    •    google/appengine/api/ mail: 80% (usable)
    •    google/appengine/api/ images: 60% (usable)
    •    google/appengine/api/ users: 90% (usable)
    •    google/appengine/api/labs/ taskqueue: 80% (usable)
    •    google/appengine/ext/ db: 80% (usable, expect minor API changes)
    •    google/appengine/ext/ db/forms: 60% (usable, expect API changes)
    •    google/appengine/api/ xmpp: 80% (usable)
    •    google/appengine/ext/ blobstore: 50% (usable)
    •    google/appengine/api/ oauth: 90% (not tested)

You can download AppengineJS at GitHub.  The SDK is part of the Nitro Ecosystem and tracks the latest developments in the CommonJS group.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}