Go implementation of a HTTP server to allow remote generation of mermaid-js diagrams without any pre-requisites installed locally.
Go to file
dependabot[bot] f95701f228
Bump golang from 1.15-buster to 1.16.6-buster (#5)
Bumps golang from 1.15-buster to 1.16.6-buster.

---
updated-dependencies:
- dependency-name: golang
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-28 22:15:51 +02:00
.github Bump actions/setup-go from 1 to 2.1.3 (#2) 2021-07-28 22:12:24 +02:00
cmd/app Rework some things to prepare for the cleanup of old diagrams 2020-08-08 00:21:39 +01:00
internal Do some cleanup and add a Makefile 2020-10-02 14:33:34 +01:00
mermaidcli Bump @mermaid-js/mermaid-cli from 8.6.4 to 8.11.0 in /mermaidcli (#6) 2021-07-28 22:15:17 +02:00
.gitignore Initial commit with basic HTTP endpoint working 2020-04-06 23:25:47 +01:00
Dockerfile Bump golang from 1.15-buster to 1.16.6-buster (#5) 2021-07-28 22:15:51 +02:00
Makefile Do some cleanup and add a Makefile 2020-10-02 14:33:34 +01:00
README.md feat(png): add support for generating the images as png 2020-10-01 19:25:40 +02:00
example.png Add example image 2020-04-06 23:29:21 +01:00
go.mod Bump github.com/tomwright/lifetime from 1.0.0 to 1.0.1 (#7) 2021-07-28 22:14:52 +02:00
go.sum Bump github.com/tomwright/lifetime from 1.0.0 to 1.0.1 (#7) 2021-07-28 22:14:52 +02:00

README.md

mermaid-server

Use mermaid-js to generate diagrams in a HTTP endpoint.

While this currently serves the diagrams via HTTP, it could easily be manipulated to server diagrams via other means.

Basic usage

Docker

Run the container:

docker run -d --name mermaid-server -p 80:80 tomwright/mermaid-server:latest

Manually as a go command

Start the HTTP server:

go run cmd/app/main.go --mermaid=./mermaidcli/node_modules/.bin/mmdc --in=./in --out=./out

Diagram creation

Use the query param 'type' to change between 'png' and 'svg' defaults to 'svg'.

POST

Send a CURL request to generate a diagram via POST:

curl --location --request POST 'http://localhost:80/generate' \
--header 'Content-Type: text/plain' \
--data-raw 'graph LR

    A-->B
    B-->C
    C-->D
    C-->F
'

GET

Send a CURL request to generate a diagram via GET... send in url encoded data under the data query param:

curl --location --request GET 'http://localhost:80/generate?data=graph%20LR%0A%0A%20%20%20%20A--%3EB%0A%20%20%20%20B--%3EC%0A%20%20%20%20C--%3ED%0A%20%20%20%20C--%3EF%0A'

Example request in Postman

Caching

All generated diagram input and output will be cached for 1 hour. The cache time is reset whenever a cached diagram is accessed.