At my day job we use Postgres as our primary data store and Node.js for a lot of our services. I had heard about PLV8 before but hadn’t had a chance to give it a try. Here is a simple example:
In this example blob is a JSON column in the snapshot table. I know this could be easily done with the JSON functions but there will definitely be times where PLV8 is the simpler solution.
As I mentioned in my previous post I came across Spark Framework and was intrigued that java might have finally reached the level of simplicity to make it viable as a prototyping language for rest services.
Just to start things off easy I went with a simple time service:
Line 2 is wiring up the public resources that will be used shortly. Line 3-4 is returning the current time in miliseconds for a GET to /time.
To keep things more interesting I decided to throw in another technology that has been a buzz lately but I haven’t had time to pick it until now. And that is React.
This is my first react app so it probably is a little messy but you have to start somewhere. Basically it starts of setting the currentTime to empty string and as soon as the component is bound it will make a request to our spark rest API. Once the result is received, currentTime will be updated which is where the magic of React comes in and updates the corresponding UI elements.
Just for good measure here is a docker file that bundles up this spark app:
A few weeks I looked back at Java for a new REST API after a long time away with Node.js. After a little bit of looking I came across Spark Framework. It was interesting to see that a Java Rest framework was at the level of simplicity of its dynamic counter parts. For example:
When the simplest this was pretty much on par with a hello world for express.js