Use bpmn-engine in React app

Hello, i have created a react app where i have embedded bpmn modeler and now i want to be able to execute my diagrams using the bpmn-engine. However i cannot get it to work. I followed the example i found in github but i get an error that says: ‘TypeError: TypeResolver is not a function’. I dont understand what I’ve done wrong. My project was created using ‘npx create-react-app’

ok so basically i just created a separate nodejs app that runs the engine and i execute diagrams using axios.post and pass any options required like that. this is my server.js:

const express = require('express');
const cors = require('cors');
const app = express();
const port = //whatever;
const BPMN = require('bpmn-engine');

const camunda = require('camunda-bpmn-moddle/resources/camunda.json');

app.use(express.json());
app.use(cors());

app.post('/api/execute', async (req, res) => {
    try {
        const { name, source, variables } = req.body;
        const engine = new BPMN.Engine({
            name: name,
            source: source,
            variables: variables,
            moddleOptions: {
                camunda
            }
        });
        engine.execute((err, execution) => {
            if (err) {
                res.status(422).json({ error: `${err.message}` });
                return;
            }
            res.json({ message: `Execution completed with id ${execution.environment.variables.id}` });
        });
    } catch (error) {
        res.status(500).json({ error: 'An error occurred' });
    }
});

app.listen(port, () => { console.log(`Server started on port ${port}`); });

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.