Headless Bug Hunting!

JavaScript Test Automation

It’s been some time since my last post having taken a break to go get married, have a honeymoon, start a new work engagement among other adventures. I have been working on various projects related to IoT along with the continued pursuit of learning which web frameworks and have finally become pretty happy with a recent pattern of using ASP.NET MVC -> TypeScript -> AngularJS -> JasmineJS -> PhantomJS.

We’ve all seen the basics of putting together SPA applications with AngularJS within an MVC application so I won’t repeat much of that infrastructure. I’ve talked about TypeScript before in a post called “Every JavaScript Program is also a TypeScript Program?” and I’d even mentioned a little here about tsUnit as a test framework specifically for TypeScript, but this only solved a very specific piece of the puzzle.

What I wanted to see was a full fledge, similar to what I’m used to seeing with unit/integration testing on the server-side but for JavaScript. This meant that I first needed a standard way to reference existing JavaScript modules (generated from TypeScript, of course) and write unit tests against them which could then be aggregated and executed both by test runner tooling within Visual Studio as well as something portable that could be shared. Jasmine solved this for me, but how could I tie that into CI and execute it headless to further integrate into other processes during build & deployment? This is where Phantom came in.


Practical Node MVC with SailsJS

What is SailsJS?


Built on top of NodeJS, Express and Socket.io, SailsJS is a back-end web framework designed to standardize an MVC implementation with common implementation for both http and sockets. Sails also brings an extensible, opt-in suite of modules to solve a lot of the scaffolding right out of the box. Built as 100% JavaScript, Sails gives us the ability to auto-generate REST apis by leveraging convention over configuration, support for Web Sockets with no additional coding, declarative & reusable security policies and a built in ORM framework called Waterline (the nautical theme continues throughout)..


Node-RED – JavaScript GPIO!

A Visual Wiring Tool for IoT with NodeJS!

After hearing about Node-RED for the second time yesterday at our local ALT.NET user group’s “Introduction to the Raspberry Pi” meet-up, I decided to give this a closer look to see what all the fuss was about. What is Node-RED? It’s a tool built on NodeJS made for wiring together various devices such as the Raspberry Pi, Arduino & Beaglebone Black, for example, along with other various online services. It also gives you a browser-based flow editor to design steps in the process with a simple one-click deployment to push this out to the runtime. JavaScript functions can be created within the editor using the rich capabilities of the embedded Eclipse Orion. A built-in library allows you to save useful functions, templates or flows for re-use.



Welcome to the Windows Developer Program for IoT!

Christmas in September!

Ok, maybe it’s not that exciting, but today I received my Windows Developer Program for IoT kit and I am quite excited to see what I can build with it. If you haven’t heard of the program, check out http://windowsondevices.com to learn, make, explore and connect with others in the program. For those of us lucky enough to have been selected, we received a kit to get started with an Intel Galileo board, USB/Ethernet adapter & cable, small LED, power supply and MicroSD pre-loaded with Microsoft Windows for the Intel Galileo.

What is a Galileo?

The Intel Galileo v1 is a hardware development board that contains a Quark CPU and a number of hardware device interfaces, including I2C, UART, SPI, GPIO, USB, and PCI-E. The pin arrangement on the Galileo complies with the Arduino hardware spec, meaning the Galileo itself qualifies as an “Arduino board”. This version of Galileo is “headless”, meaning it has no on-board video outputs. Intel’s documentation can be found here: https://communities.intel.com/community/makers/documentation/galileodocuments


Using Http Interceptors For Framework Services

What is an Http Interceptor?

The $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser’s XMLHttpRequest object or via JSONP. There are times when we might want to intercept requests or responses before they are returned to the calling code within the application handling the requests. Error handling, authentication or other various pre-processing of requests may be examples of where these scenarios may require an http interceptor.

Interceptors make use of the promise APIs which are currently provided by the q framework in AngularJS to handle synchronous and asynchronous pre-processing. There are four types of receptors:

  • request: interceptors get called with a http config object. The function is free to modify the config object or create a new one. The function needs to return the config object directly, or a promise containing the config or a new config object.
  • requestError: interceptor gets called when a previous interceptor threw an error or resolved with a rejection.
  • response: interceptors get called with http response object. The function is free to modify the response object or create a new one. The function needs to return the response object directly, or as a promise containing the response or a new response object.
  • responseError: interceptor gets called when a previous interceptor threw an error or resolved with a rejection


Working with JSON Web Tokens (JWT) with JavaScript only?

The Challenge

Recently, I posted on an Identity Infrastructure for developers called Auth0. I’ve been working more with the tool recently and have become a bigger fan the more that I have had experience solving issues readying a true enterprise solution for a client. I don’t plan to re-explore the Auth0 platform in this post, but during a specific test I found myself needing to explore validating a JSON Web Token (JWT) on the client-side along with being able to insert additional claims for authorization purposes. I’d accomplished some of this with NodeJS as well as with C# on the server side, but in the case of the implementation where I have events hooked within my AngularJS SPA, for loginSucceeded for example, I wanted to handle additional authorization needs by adding additional temporary claims specific to the particular module being used at the time. (more…)

Raspberry Pi Remote Controlled Light Show

PiGlow Django & Angular!

In this week’s post, I wanted to share a little project that I put together using a PiGlow connected to my Raspberry Pi that I can control via a phone or any other browser on my home network. This helped me to finalize a framework for working with the Pi remotely by hosting a NodeJS based Express 4 website which used AngularJS/Bootstrap for a front-end which communicated with a service built on the DJango rest framework which can provide RESTful endpoint access for executing Python scripts which can work with the GPIO on the Pi board. This is only starting point but did prove to be both a fun and challenging experiment!


MEAN Raspberry Pi Home Web Server (Part 3)

Finishing the Starter Site

Setting up a website for your home (Part 1)
MEANRPi Home Web Server (Part 2)

In the previous two posts, we’ve worked through from the initial Raspberry Pi B Model Setup, through working headless and on the XDesktop environment through installing NodeJS, ExpressJS, AngularJS and completing the first couple of views in a Single Page Application (SPA) hosted by the Raspberry Pi accessible on any device on the home network. The next and final piece in this series will be to leverage a data management technology for structured, semi-structured and unstructured data. To do this, I’ll be adding MongoDB to my environment which is currently the leading NoSQL database.



MEANRPi Home Web Server (Part 2)

Additional Plumbing..

In last week’s post “Setting up a website for your home (Part 1)“, we went through the process of setting up a very basic web server using Express running on NodeJS on the Raspberry Pi. This provided the basic ability to serve a static HTML page to any client browser on the home network. The longer-term objective is to have a home web site that gives access to various applications developed as part of my home automation and tooling experiments. With the idea that folks at home may access this site with various devices and there may be more than just top-level links, I wanted to take the next step of providing a basic responsive interface that includes a simple SPA (Single Page Application) built on AngularJS. For those familiar with the “MEAN stack”, this would give us the E (Express), A (Angular) & the N (Node) so we’ll round it out in the next installment with a bit of MongoDB. Since this is running on a RaspberryPi, I thought it clever to refer to this as my “MEANRPi” server. (more…)

Setting up a website for your home (Part 1)

The Mission

I’ve finally decided to peek into the interesting concept of the “Internet of Things” (IoT). As I thought about the various types of micro-controllers and applications, it was tough to decide where to start. While I hadn’t decided on a great first project, I was pretty sure that I’d end up doing many projects and that I’d surely need an interface to control everything. This led me to the decision to set out to build a web server on a device that’s lightweight and accessible on my home network. Sounds simple enough, right?

Using this IoT adventure as a way to force myself further out of my comfort zone of building .NET/JavaScript-based projects all day at the office, I knew that I didn’t want to begin learning on a Netduino micro-controller because that would just be “too easy” since this would mean working on my Windows laptop with Visual Studio writing with the .NET Netduino SDK. That’s not all that different from what I do all the time. As I thought about the idea of working on a different operating system (i.e. Linux running on the Raspberry Pi), using a different language (Python on the Pi) and communicating with other micro-controllers also using different languages (C/C++ on Arduinos), this seemed more like what I was after!

This led me to the first step in my process – get myself a Raspberry Pi and set up a basic web server running on NodeJS with Express. This would allow me to display important information about any of the applications that I have going on for the home and ideally control all or at least some of these from this interface accessible from any device on the network. (more…)