| Total Complexity | 6 |
| Complexity/F | 1.5 |
| Lines of Code | 33 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | import path from 'path' |
||
| 2 | import { |
||
| 3 | cmsOperations, |
||
| 4 | abeExtend, |
||
| 5 | Manager |
||
|
|
|||
| 6 | } from '../../cli' |
||
| 7 | |||
| 8 | var route = function(req, res, next){ |
||
| 9 | abeExtend.hooks.instance.trigger('beforeRoute', req, res, next) |
||
| 10 | if(typeof res._header !== 'undefined' && res._header !== null) return |
||
| 11 | |||
| 12 | var filePath = req.originalUrl.replace('/abe/publish', '') |
||
| 13 | var json = req.body.json |
||
| 14 | |||
| 15 | var p = cmsOperations.post.publish( |
||
| 16 | filePath, |
||
| 17 | json.abe_meta.template, |
||
| 18 | json |
||
| 19 | ) |
||
| 20 | |||
| 21 | p.then((result) => { |
||
| 22 | res.set('Content-Type', 'application/json') |
||
| 23 | res.send(JSON.stringify(result)) |
||
| 24 | }, |
||
| 25 | (result) => { |
||
| 26 | res.set('Content-Type', 'application/json') |
||
| 27 | res.send(JSON.stringify(result)) |
||
| 28 | }).catch(function(e) { |
||
| 29 | console.error('[ERROR] post-publish.js', e) |
||
| 30 | }) |
||
| 31 | } |
||
| 32 | |||
| 33 | export default route |