Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability for WS client to publish MQTT messages to topics #16

Merged
merged 26 commits into from
Oct 24, 2023

Conversation

ddellacosta
Copy link
Owner

@ddellacosta ddellacosta commented Sep 22, 2023

2023-10-24_10-46

This should probably have been three separate PRs, especially considering the size, although ~1/3 of the lines added in this PR are auto-generated boilerplate in ui/package-lock.json.

In any case, here are the main chunks of functionality introduced, along with pointers and context for the most important pieces of each:

  • The main functionality introduced is as the title describes: this PR provides the ability to publish MQTT messages over a WebSocket connection via the HTTP client. This is exposed through the user interface in a simple text input field and "Publish" button as is seen in the screenshot above. This has been tested manually, and there are integration tests for the backend and frontend pieces of this introduced in this PR as well. Introducing acceptance tests is in the queue.

  • Speaking of tests, this PR introduces frontend tests via purescript-spec and elmish-testing-library. If this software was being made in a more professional way, test scaffolding would have been its own PR probably in advance of any actual frontend production code, or at least with the first frontend code introduced, but I kinda skipped it 😅

  • Spago has been upgraded to Spago Next. There is no reason to do this other than the fact that, when I looked in the spago repo for information on overriding dependencies with local directories, I realized a new version was being introduced, and I figured I may as well just upgrade spago while I was at it. Had I been working on this at a company or if this project was used by more people than just me, I would have skipped this. None of it was too hard, but it ended up being quite involved and the entire frontend build chain and configuration setup changed, which is not something I'd want to do to other developers without a discussion, or arbitrarily change in a production environment without a lot of testing.

    Most importantly, this included swapping out my previous method of loading PureScript and associated dependencies via easy-purescript-nix for just loading the PureScript dependency directly from nix and installing the rest via npm, as the latest spago isn't available via easy-ps-nix. I'm not sure I love this, as I don't love depending on npm any more than I absolutely have to, but it's fine so far. I also want to see if I can use https://github.com/thomashoneyman/purescript-overlay or what Dennis was working on, https://github.com/purifix/purifix, but those two will have to wait for future experiments. Anyways, will use this until it is a problem. This should let me stay more up-to-date vs. being beholden to easy-ps-nix to update its dependencies, at least. ¯_(ツ)_/¯

    Changes:

Final addendum: a bunch of Haskell dependencies got bumped too. I'm embarrassed to say I think this was a byproduct of nix tweaks when I updated spago, but I'm not sure 😅 ...on the other hand, I was finally able to bump the tls library to version 1.6.0, which removes SSLv3 support, which is nice.

P.S. it should go without saying that, because I'm the only one who reviewed this, there are almost definitely things I've missed.

@@ -157,7 +157,7 @@ mkRunAutomation filepath = \_broadcastChan -> do

loadScript :: FilePath -> FilePath -> Lua.LuaE Lua.Exception Lua.Status
loadScript luaScriptPath' filepath =
Lua.loadfile $ luaScriptPath' <> filepath <> ".lua"
Lua.loadfile . Just $ luaScriptPath' <> filepath <> ".lua"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easy-ps.purs-tidy
pkgs.nodejs_20
pkgs.purescript
pkgs.nodejs_18
Copy link
Owner Author

@ddellacosta ddellacosta Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addresses an issue with GlobalRegistrator in Happy Dom (via elmish-testing-library), although I'm leveraging the fact that whatever is at 18 in nix is lower than 18.18.2, apparently >= is problematic

@ddellacosta ddellacosta marked this pull request as ready for review October 24, 2023 14:27
@ddellacosta ddellacosta merged commit 6e2d1ef into main Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant