-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (27 loc) · 811 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var bp = require('./main/bpmn.js');
var bodyParser = require('body-parser');
var Q = require('q');
var getBPJSON = function(req,res){
bp.bpm2json().then(function(data){
console.log(data);
res.status(200);
res.end(JSON.stringify(data));
});
}
var postBPJSON = function(req,res){
bp.bpmn2jsonP(req.body.xml,req.body.name).then(function(data){
console.log("JSON: ",data);
res.status(200);
res.end(JSON.stringify(data));
});
}
var express = require('express')
var app = express();
app.use(bodyParser.json()); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
app.use(express.bodyParser({uploadDir:'./uploads'}));
app.get('/bpmn',getBPJSON);
app.post('/bpmn2json',postBPJSON);
app.listen(3000);