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

chore: diagrams.net - add /health API for health checks #1811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions diagrams.net/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { SyntaxError, TimeoutError, Worker } from './worker.js'
const worker = new Worker(browser)
const server = new http.Server(
micro.serve(async (req, res) => {
// Add a /health route that renders a sample diagram by calling the worker
if (req.url === '/health') {
let sample = `<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel>`
await worker.convert(new Task(sample, false), new URLSearchParams())

// We don't actually care about the output, we just want to make sure the worker is up and running
return micro.send(res, 200, 'OK')
}
// TODO: add a /_status route (return diagrams.net version)
// TODO: read the diagram source as plain text
const url = new URL(req.url, 'http://localhost') // create a URL object. The base is not important here
Expand Down