An open API service indexing awesome lists of open source software.

https://github.com/jlkdevelop/try-mxscript

Source for try.mxscript.com — the official MX Script browser playground. Built entirely in MX Script.
https://github.com/jlkdevelop/try-mxscript

Last synced: about 1 month ago
JSON representation

Source for try.mxscript.com — the official MX Script browser playground. Built entirely in MX Script.

Awesome Lists containing this project

README

          

# try-mxscript

Source for [**try.mxscript.com**](https://try.mxscript.com) — the official browser-based playground for [MX Script](https://github.com/jlkdevelop/mxscript).

> Created by [Jassim Alkharafi](https://github.com/jlkdevelop). MIT-licensed and built in the open.

## Why this repo exists

The whole site is **one `.mx` file**: [`app.mx`](./app.mx). Every byte of HTML, CSS, and client-side JS is generated by MX Script functions, and the **Run** button is powered by MX Script's own [`eval()`](https://github.com/jlkdevelop/mxscript/blob/main/CHANGELOG.md) builtin (added in v0.43+).

In short: the playground that runs your `.mx` code is itself written in MX Script.

## Architecture

```
┌─────────────────────────────────────────────────────┐
│ Browser │
│ GET / → landing_page() returns HTML │
│ GET /examples → JSON list of curated snippets │
│ POST /run → { source } → JSON result │
│ GET /healthz → JSON heartbeat │
└─────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────┐
│ app.mx │
│ eval(source, { timeout_ms: 5000 }) │
│ ├── lex + parse │
│ ├── exec in a fresh Interpreter │
│ ├── capture stdout via child.Out buffer │
│ └── enforce 5s wall-clock timeout │
└─────────────────────────────────────────────────────┘
```

`eval()` does **not** start an HTTP listener even if the snippet declares `server { }` or routes — it only evaluates top-level statements. That's what makes the playground safe to run inside a request handler.

## Run locally

You need [`mx` v0.43+](https://github.com/jlkdevelop/mxscript) on your `$PATH`:

```bash
mx run app.mx
# → http://localhost:8080
```

## Deploy

This repo deploys to Vercel via MX Script's built-in adapter:

```bash
mx build --vercel
git add main.go go.mod vercel.json
git commit -m "Deploy via mx build --vercel"
git push # Vercel autodeploys on push
```

The generated Go shim embeds `app.mx`, lexes/parses/loads it via the interpreter library, and serves the resulting handler on Vercel's `$PORT`.

## License

[MIT](./LICENSE) © Jassim Alkharafi