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

How to use mermaid on node.js restful api? #593

Closed
robertrita opened this issue Nov 14, 2017 · 2 comments
Closed

How to use mermaid on node.js restful api? #593

robertrita opened this issue Nov 14, 2017 · 2 comments

Comments

@robertrita
Copy link

I'm not an expert with javascript. Below is how I did it.
expected output: .svg or .png file that I can show on the response as full path.
Please help. thanks.


const express = require('express');
const mermaidAPI = require('mermaid');

app.get('/chart', (req, res) => {
mermaidAPI.initialize({
startOnLoad: true
})
const graphDefinition = 'graph TB\na-->b'
const cb = function(svgGraph) {
console.log(svgGraph)
}
mermaidAPI.render('id1',graphDefinition,cb)

res.status(200).json('.svg or .png file path here!');

})

@aimed
Copy link

aimed commented Dec 6, 2017

You can use the mermaid.cli to create the image serverside, then serve it.
If you don't want to use the cli, look at how it uses a headless browser (puppeteer) to generate the files.

@tylerlong
Copy link
Collaborator

@aimed is correct. Please refer to https://github.com/mermaidjs/mermaid.cli

mgenereu pushed a commit to mgenereu/mermaid that referenced this issue Jun 25, 2022
…yarn/develop/eslint-plugin-tailwindcss-3.3.0

chore(deps-dev): bump eslint-plugin-tailwindcss from 1.17.2 to 3.3.0
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

No branches or pull requests

3 participants