This entry is part 1 of 9 in the series WS + API: A NodeJS Server

This is a funny post to write because just yesterday I was sitting at my desk and very tired, wondering if I wanted to continue with Horizon Forbidden West, Lightyear Frontier, Return to Moria, or maybe watch TV in our newly renovated basement entertainment room. What I knew I did not want to do was program. As far as I was concerned, I was rapidly approaching being completely done with application development, game development, and anything and everything that required curly brackets which posed a major problem because that is literally my day job. Was I really done? Was this my own Great Resignation, then? And at my age? What the hell was I going to do for the next 30 years before I can even think about considering the possibility of retirement?

Something changed between then and this morning, though, because I got an insane urge to refactor my Node web socket server for no good reason. Well, not no good reason because I started this project for my day job, but other more important projects got in the way so the server was shelved. I had been documenting my progress in Obsidian, so I thought I’d revisit my notes and start a new version with some enhancements I’d been considering.

All In One

Since picking up React, I’ve had to resort to RESTful API in order to work with data, and since I had switched to React from C# MVC, I have been creating my endpoints using .NET’s web-API design. While I’ve gotten creating endpoints down to a science this way, I’ve also been working a lot with Docker, Redis, and my home Linux server which has been pulling me away from .NET after something like 20 years.

To that end, I started designing my Node web socket server to also serve API endpoints via Express. I wanted this server to be able to handle both the occasional data request through the API while also serving as an always-connected hub, and having both in one server would also mean I could cross boundaries and use an endpoint request to send data through web sockets should the need arise.

Since refactoring and rebuilding my initial project, I decided to create a basic server implementation that could be extended easily without having to dig into the core of the application. It’s still got a ways to go, but since I need to rebuild my post-count here on the site, I thought I’d spend the next few days going through the parts that have already been done and tested with some success.

Scopique

Husband, father, gamer, developer, and curator of 10,000 unfinished projects.