Building industrial-strength M-based REST APIs using mg_web and mgweb-server

118 views
Skip to first unread message

rtweed

unread,
Nov 20, 2020, 9:40:26 AM11/20/20
to Enterprise Web Developer Community
Recently my colleague Chris Munt recently published his mg_web repository:


This provides a modern and high-performance solution for connecting the main industrial-strength web servers (IIS, Apache and NGINX) to an M system (YottaDB, Cache or IRIS), allowing web applications and REST services to be built in M code or ObjectScript

I've now built something I'm calling mgweb-server on top of mg_web:


This provides an off-the-peg standard way to configure and use mg_web to rapidly and simply create JSON-based REST APIs using an M back-end (ie again, all the handler code can be written in M or ObjectScript).

I've made it even easier for you to try out by creating a pre-built, ready-to-run-out-of-the-box Dockerised version which incorporates YottaDB, the web server, mg_web and mgweb-server, all installed, configured and set up for you.  There's a Docker container for Linux (which uses NGINX as the web server) and for the Raspberry Pi (which uses Apache as the web server).

Linux: docker pull rtweed/mgweb
Raspberry Pi: docker pull rtweed/mgweb-rpi

To provide a ready-to-run example of how it can all be used and to provide an exemplar for how to develop REST APIs using these technologies and to show those APIs working within a browser-based application, I've also created the mgweb-conduit repository:


Those of you familiar with my Node.js-based QEWD work will recognise that I did something similar for it - qewd-conduit.

Both implement the so-called RealWorld Conduit back-end APIs, and indeed, both share the exact same underlying Global data model for the Conduit dataset.  The qewd-conduit one abstracts it as persistent JSON objects, while mgweb-conduit uses plain old M code and the actual underlying Globals to achieve the exact same functionality.

Follow the instructions in mgweb-conduit's README document and you'll have it all up and running in a matter of minutes.

mg_web and mgweb-server could be just the thing for those of you who want to web-enable M applications such as VistA, just using M code (or Cache/IRIS ObjectScript, Classes and SQL), but making use of proper industry-standard, commercial-strength web servers.

Enjoy!

wdbacker

unread,
Nov 20, 2020, 9:59:19 AM11/20/20
to Enterprise Web Developer Community
Rob, really great job, congrats! :-)

rtweed

unread,
Nov 24, 2020, 10:10:15 AM11/24/20
to Enterprise Web Developer Community
I've updated the Containers to allow the YottaDB Global files to be mapped into a host directory, so that your YottaDB data will be retained between Container restarts.

Setting your Container up to do this is very simple and fully documented in the mgweb-server repository's README file:


I do hope some of you try out this new technology - all Open Source and free for anyone to use.  Do let me know how you get on with it

Rob

OldMster

unread,
Nov 24, 2020, 4:52:57 PM11/24/20
to Enterprise Web Developer Community
Rob,
Great job!  I'm looking forward to digging in to this after the holiday this week (here in the U.S. anyway)

Mark

rtweed

unread,
Nov 25, 2020, 10:17:38 AM11/25/20
to Enterprise Web Developer Community
A further update: I've updated the mgweb-server and mgweb-conduit repositories and added to their README files instructions on how to use IRIS with the mgweb-server Container.  You can can have Apache and mg_web running in the mgweb-server container, connected to the IRIS Community Edition Container, where the actual M/ObjectScript routines run and the ^conduit* Globals are maintained.  All do-able in just a few minutes!

See:

rtweed

unread,
Dec 3, 2020, 1:53:19 PM12/3/20
to Enterprise Web Developer Community
Two new detailed tutorials, one on using mg_web and mgweb-server with YottaDB, the second the equivalent for IRIS:

Rob

OldMster

unread,
Dec 20, 2020, 2:17:23 PM12/20/20
to Enterprise Web Developer Community
Thanks for this Rob!  Great explanations.  I'm switching from Flex to Vue3, which means switching from XML to JSON for my REST calls.  MGWSI does not seem to be able to accept a post request with a JSON payload, so it appears I'll be switching to mg_web in the near future.

I've been waiting for Vue3 for a while, it is finally here, and is quite nice.  The documentation is sketchy, it assumes you know everything already, and I'm not fully up to speed on javascript yet (a rapidly moving target), let alone NPM, YARN, WebPack and about a bazillion other things they always assume you know all about, and then fail to go into any details about how it all works together.  Your documentation/tutorial goes into the behind the scenes 'stuff' that I can't seem to learn anything with out knowing, even if I don't have to delve into it often.  If you're interested in Vue3, the best I've found so far is a video series 'Vue Mastery'.  I'd rather have book, it is annoying having to go back and forth in the various videos to find something I know I saw but don't remember the details of.

Reply all
Reply to author
Forward
0 new messages