Upgrade to Pro — share decks privately, control downloads, hide ads and more …

State of RingoJS

State of RingoJS

Presenting the current state of RingoJS and how easy you can deploy your application on Google App Engine.

Philipp Naderer

December 16, 2013
Tweet

More Decks by Philipp Naderer

Other Decks in Programming

Transcript

  1. What is RingoJS? • RingoJS is not Node • JavaScript

    on the JVM • Multithreaded JavaScript • Based on Mozilla Rhino • Successor of Helma • CommonJS Module System • CommonJS Modules • JSGI for Web Services
  2. Progress since last ViennaJS • Growing ecosystem, more packages •

    Chainable ringo/jsgi/response • Improved ringo/httpclient • Bugfixes and better test coverage • New website and more documentation • More real world deployments
  3. Destructoring Assignments var a = 1, b = 3; !

    // Swap values of a and b [a, b] = [b, a]; ! // Extract foo and bar properties // from mymodule var {foo, bar} = require("mymodule");
  4. Chainable JSGI Response var response = require("ringo/jsgi/response"); var {Application} =

    require("stick"); var app = new Application(); app.configure("params", "route"); ! app.get("/", function(req) { var title = req.queryParams.title; ! return response.html("…") .setStatus(402).addHeaders({…}); });
  5. Ringo on Google App Engine • Easy to integrate since

    Ringo runs on the JVM • No compiling needed, hot reload of scripts • Access all the Java APIs from GAE • Datastore API • Cloud SQL • Service APIs (OpenID, Images, …)
  6. App Engine Demo // Note: packages prefixed with com.google. importPackage(appengine.api.users);

    importPackage(appengine.api.images); importPackage(appengine.api.datastore); importPackage(appengine.api.blobstore); ! var userService = UserServiceFactory.getUserService(); ! userService.isUserLoggedIn(); userService.createLoginURL(requestURL);
  7. App Engine Demo var datastore = DatastoreServiceFactory.getDatastoreService(); var bs =

    new Entity("Bookshelf"); bs.setProperty("title", req.postParams.title); bs.setProperty("created", new java.util.Date()); bs.setProperty("creator", credentials.currentUser); ! datastore.put(bs); return response.redirect("/bookshelf/" + bs.getKey().getId());
  8. App Engine Demo var book; try { book = datastore.get(bookKey);

    ! } catch (e if e.javaException instanceof EntityNotFoundException) { ! // return 404 - File not Found ! } catch (e) { // return 500 - Internal Error }
  9. App Engine Demo var blobstoreService = BlobstoreServiceFactory.getBlobstoreService(); ! var blobs

    = blobstoreService.getUploads( req.env.servletRequest ); ! var imgservice = ImagesServiceFactory.getImagesService(); ! imgservice.getServingUrl( ServingUrlOptions.Builder.withBlobKey(blobKey) );