| Total Complexity | 4 |
| Complexity/F | 1 |
| Lines of Code | 35 |
| Function Count | 4 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import { |
||
| 2 | cmsOperations, |
||
| 3 | abeExtend |
||
| 4 | } from '../../cli' |
||
| 5 | |||
| 6 | var route = function(req, res, next) { |
||
| 7 | abeExtend.hooks.instance.trigger('beforeRoute', req, res, next) |
||
| 8 | |||
| 9 | var filepath = req.originalUrl.replace('/abe/duplicate', '') |
||
| 10 | var folderName = filepath.split('/') |
||
| 11 | var postName = folderName.pop() |
||
| 12 | folderName = folderName.join('/') |
||
| 13 | |||
| 14 | var p = cmsOperations.duplicate(req.body.oldFilePath, req.body.selectTemplate, folderName, postName, req) |
||
| 15 | |||
| 16 | p.then((resSave) => { |
||
| 17 | var result = { |
||
| 18 | success: 1, |
||
| 19 | json: resSave |
||
| 20 | } |
||
| 21 | res.set('Content-Type', 'application/json') |
||
| 22 | res.send(JSON.stringify(result)) |
||
| 23 | }, |
||
| 24 | () => { |
||
| 25 | var result = { |
||
| 26 | success: 0 |
||
| 27 | } |
||
| 28 | res.set('Content-Type', 'application/json') |
||
| 29 | res.send(JSON.stringify(result)) |
||
| 30 | }).catch(function(e) { |
||
| 31 | console.error('[ERROR] get-duplicate.js', e) |
||
| 32 | }) |
||
| 33 | } |
||
| 34 | |||
| 35 | export default route |