Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Bundle HTML, CSS, And JavaScript To Be Served In A Golang Application

So I’ve been working on a project that uses the Go programming language. The application I’m building is a web application that I plan to distribute. The thing is, I don’t want to distribute hundreds of files to make it possible. The application has an API built with Go and the front-end that consumes the API is built with Angular. This lead me searching for a way to bundle all the files into the final binary.

There are several packages that exist for bundling assets into a Golang application. Popular packages include go-bindata, go-bindata-assetfs, and go.rice. I had the most success with go.rice, so we’re going to explore it in this article.

Read More

Use NGINX As A Reverse Proxy To Your Containerized Docker Applications

You might have noticed that I’m doing quite a bit of Docker related articles lately. This is because I’ve been exploring it as an option for the future of my personal web applications. As of right now I’m serving several web applications on Digital Ocean under a single Apache instance. As requests come into my server, Apache routes them to the appropriate application via virtual hosts. Each application is a different directory on the virtual private server (VPS). If I were to containerize each application, things would behave a bit differently. I would need to set up a reverse proxy to route each request to a different container on the host.

While Apache can work as a reverse proxy, there are other options that work way better. For example NGINX is known for being an awesome reverse proxy solution. We’re going to see how to create several web application containers and route between them with an NGINX reverse proxy container.

Read More

Parse XML Data In A Golang Application

While I don’t see a lot of it anymore, XML is still a common data format that people use. I prefer JSON, but I don’t always have a say in how I receive data. Some time ago I wrote a few tutorials on which include parsing XML data with Node.js, parsing XML data with Java, and parsing XML data with PHP. If you’ve been keeping up, I’ve been doing a lot of development with the Go programming language which is why I think it would be a great idea to go over XML in Golang.

Of the various programming languages, I think XML is the easiest to work with in the Go programming language. We’re going to see how to take XML data and unmarshal it into a custom structure. We’re also going to see how to take JSON data and convert it into XML.

Read More

JWT Authentication In A Node.js Powered API

When it comes to API development, there is often a need to protect certain endpoints or rate-limit the API in general. Because you are working with endpoints from clients possibly on a different domain, you can’t authenticate users with sessions and cookies. It would also be a bad idea to pass around a username and password with each request. Typically endpoints are protected with tokens that are passed with each request and these tokens are often JSON Web Tokens (JWT) that work very well.

We’re going to see how to create a very simple API using Node.js with protected endpoints that require a valid JWT in order for requests to succeed.

Read More

JavaScript Libraries In A TypeScript Application, Revisited

If you haven’t already gotten involved with it, you’ll probably know that TypeScript is becoming increasingly popular. Being able to use a superset of JavaScript in a typed language that compiles down to JavaScript is a great thing. However, if you’ve ever played around with TypeScript and tried to use JavaScript libraries, you’ll probably know that sometimes it can be a real pain. Often JavaScript libraries do not ship with type definitions which are critical when it comes to playing nice with TypeScript.

If you’ve been keeping up with The Polyglot Developer you’ll probably remember two posts that were created. Previously I had written about including external JavaScript libraries in an Angular application as well as adding type definitions to external JavaScript libraries in TypeScript.

We’re going to revisit these two articles and explore all the ways to include JavaScript libraries in TypeScript applications. These include applications built with NativeScript, Ionic, and Angular.

Read More

Upload Files To A Minio Object Storage Cloud With Node.js And Multer

The recent Amazon S3 outage that took down much of the internet inspired me to talk about alternatives. Not too long ago I wrote about an open source object storage software called Minio and how I was using it on my Raspberry Pi for backups. The great thing about Minio is it shares the same APIs as AWS S3, but can be deployed to your own hardware, eliminating Amazon as a dependency.

This time around I thought it would be great to share how to use Minio as an object storage for a Node.js application that uses the middleware, Multer, for handling file uploads.

Read More

Connecting To A Detached Docker Container For Terminal Interaction

When I use Docker, most of the time I start my containers in detached mode, meaning that the container will deploy in the background without any further interaction from myself. However, every once in a while I find myself needing to connect to the container to view log information.

So how do you connect to a detached container that is already running? We’re going to take a look at how to do this with minimal effort.

Read More