Skip to content

Commit

Permalink
feat: serverless api
Browse files Browse the repository at this point in the history
  • Loading branch information
scarqin committed Apr 21, 2022
1 parent 036660e commit e7cc2d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dist/
!src/core/market/browser/**/*.js
!src/core/market/browser/dist/icon.png
!src/workbench/node/request/**/*.js
!src/workbench/browser/api/*.js
!/api/*.js


# dependencies
Expand Down
28 changes: 28 additions & 0 deletions api/unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
let _LibsFlowCommon = require('../src/workbench/node/request/unit.js');
let _LibsCommon = require('../src/workbench/node/request/libs/common.js');

module.exports = (req, res) => {
console.log('unit.js', req.body);
try {
let data = req.body.data;
data.env = _LibsCommon.parseEnv(data.env);
new _LibsFlowCommon.core().main(data, (tmpInputReport, tmpInputHistory) => {
['general', 'requestInfo', 'resultInfo'].forEach((keyName) => {
if (typeof tmpInputHistory[keyName] === 'string')
tmpInputHistory[keyName] = JSON.parse(tmpInputHistory[keyName]);
});
res.send(
JSON.stringify({
action: 'finish',
data: {
id: req.body.id,
report: tmpInputReport,
history: tmpInputHistory,
},
})
);
});
} catch (e) {
console.error('unit.js', e, req.body);
}
};

0 comments on commit e7cc2d2

Please sign in to comment.