SharePoint REST API proxy for local serve in Node.js

On the recent webcast dedicated to SharePoint Framework hosted by Rencore (SPFx Deep Dive Webinar on Wednesday, 31th of August) and driven by Bill Baer mostly, there were some interesting ideas, recommendations, and thoughts.

As for me this "dive" was not so deep and actually looked more like SharePoint platform history, toolchain overview and some scratching the surface showing a couple of the examples, but it's also a good stuff as timeframes were limited.

One of the coolest thing about SPFx is a capability to run gulp serve, after which you'll find yourself in local workbench ready to add client web parts on a modern page emulator and test them in action.

One of the downsides of such local testing and debug is that you should deal with a mock generated artificial data. Maybe it only for now, maybe I understood incorrectly. But I consider that the real data is vital in many cases and real SharePoint API availability during such runtime can save hours of work and resolve tons of hassles.

I'm more than sure that later on real SharePoint API and data will be available locally within the workbench. This availability could be limited at least with REST API.

Why I'm so sure? Because it took me a single Friday night to create a REST API proxy with Node.js and Express, which allows running an application locally or on Node.js hosted server, which is actually the same, in other words, is not in the context of SharePoint page.

In such local web application page, without any deployment to SharePoint, one can execute GET or POST ajax call, let's say /_api/web/lists, which responses with the result as if an ajax call was on ShatePoint site page ~site/_api/web/lists.

Any GET or POST call is routed to the real SharePoint tenant under specified user credentials, defined in the configuration of the proxy.

Of course, such proxy is limited with REST API only. It can be a complicated task to 're-implement' JSOM, for instance. But as far we go, more and more REST significance we see in SharePoint infrastructure as a universal and language agnostic technology.

The project I created is just a concept, you can check in on GitHub. Will see what kind of power will be in SPFx for live communication with a SharePoint instance during workbench debug.