Skip to content

Instantly share code, notes, and snippets.

View abstractj's full-sized avatar

Bruno Oliveira da Silva abstractj

View GitHub Profile
@owenthereal
owenthereal / run-test262-nailgun.sh
Created October 17, 2012 03:21
Run ecmascript test262 suite for Dynjs with nailgun
#!/bin/sh
# Usage:
#
# * copy this file to the test262 folder
# * start nailgun server with `ng-server`
# * run suite with `sh run-test262-nailgun.sh <dynjs-folder>`
if [ $# = 0 ]
then
@matzew
matzew / gist:3945727
Created October 24, 2012 12:09
Private versus internal API

Not exposing implementation details

Looking at this pull request and the related discussion:

  • the Pipe interface is the only access that endusers should have to a pipe.
  • the RestAdapter is a HTTP RESTful implementation of the Pipe.
  • Endusers should not be able do do new RestAdapter(...);

Looking at the discussion of the above PR, it's clear that there exposing internal APIs and/or implementation details has PROs and CONS...

@danbev
danbev / gist:4001775
Created November 2, 2012 14:43
Handling SecurityProvider Responses in AeroGear-Controller

Handling SecurityProvider Responses within AeroGear-Controller

This gist is a follow up a previous gist that investigated using CDI events for handling SecurityProvider responses.

Background

In short, a route can be configured so that only users belonging to certain groups can access the target endpoint. For example:

route()
       .from("/delorean").roles("admin")
 .on(RequestMethod.GET)
@danbev
danbev / gist:4023803
Created November 6, 2012 09:59
AeroGear Server Side Interfaces

AeroGear Server Side Interfaces

This document describes the server side interfaces for AeroGear. Since all interactions use the Http protocol the interfaces in question are resource URLs.

Some of the exposed resource URLs are specific to AeroGear, for example if AeroGear-Security is in use, then there are certain URL that are exposed by default. But for most of the resource URLs the actual composition of the URLs is specific to the server side application. This document's indent is to be a guide for users creating new RESTful server side applications as well as for client developers to know how to interact with RESTful applications (what request/responses will look like).

Transport protocol

The APIs described in this document are based on Hypertext Transfer Protocol, version 1.1 and https is recommended. Please refer to the security section of this document for details why https is important.

Resources

A resource, or an endpoint, is identified by

@danbev
danbev / gist:4130079
Created November 22, 2012 08:55
CORS Error Response Handling

CORS Error Response Handling

According to the CORS specification, to indicate an invalid CORS request one simply does not add any CORS specific headers to the response.

There are two situations with regards to CORS Preflight request where this might cause confusion:

  1. The request is using a HTTP Method that is not supported by the server
  2. The request contains headers that are not supported by the server

In both of these cases the response status would be 200, but there will be no CORS-specific response headers. Since there are no CORS-specific headers in the response, the browser assumes the request is invalid, and doesn’t make the actual request. For both of these situations the client would see the same error:

XMLHttpRequest cannot load http://corscontroller-danbev.rhcloud.com/aerogear-controller-demo/delorean. Origin http://corsclient-danbev.rhcloud.com is not allowed by Access-Control-Allow-Origin.
@danbev
danbev / gist:4147473
Created November 26, 2012 10:02
Paging/Querying in AeroGear Controller

Paging/Querying in AeroGear Controller

This document is intended to discuss a solution for AEROGEAR-645 "Add Query/Paging support on RESTful endpoints".
This dev-aerogear mail list thread was used as a starting point to gather requirements and ideas.

Background

Lets just clarify the two concepts that we are dealing with here, Paging and Query.

Paging

Paging deals with limiting the number of results returned from a single request. One "page" can contain a certain number of items as the result of invoking a request, sometimes referred to the size of a page. Let say you want to limit you the number of result returned to 10 items, this could look something like this:

#AeroGear.AutoConfig

The idea of this utility is to provide a method to automatically configure the client side connections to server resources (Pipeline) via a request for the JSON config to the server from an AeroGear client.

Currently, to set up and use a single connection to the server (pipe) you can use the following:

// Set up a pipeline which contains one pipe using the default REST adapter
var userPipeline = AeroGear.Pipeline( "users" ),
	users = userPipeline.pipes.users;
@abstractj
abstractj / shot.js
Created July 25, 2013 20:07 — forked from ahomu/shot.js
console.log('Loading a web page');
var page = require('webpage').create();
var url = 'http://localhost:1947/';
page.viewportSize = {
width: 1024,
height: 768
};
page.open(url, function (status) {
//Page is loaded!
var iz, i = 0, queue = {};

User Management for the Aerogear Unfied Push Server

Introduction

The goal of this document is to describe how the User Management will be implemented in the Unified Push Server. Currently there is only one user created by default when installing UPS. Having the possibility to create multiple users is a "Must Have" and should be manageable from the Admin Console. Some roles should also be introduced

Roles / Permissions

//this is using promises.
dm.stores.demo.open().then( function( value ) {
var data = [
{
"id": 1,
"name": "Lea",
"type": "Skywalker"
}
];