Completed
Push — master ( 2980fc...0dcc55 )
by
unknown
02:11
created

post-duplicate.js ➔ route   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 28
rs 8.8571
nop 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A post-duplicate.js ➔ ... ➔ ??? 0 8 1
A post-duplicate.js ➔ ... ➔ p.catch 0 3 1
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