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

src/server/routes/post-update.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 35
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 4
c 1
b 0
f 0
nc 1
mnd 0
bc 4
fnc 4
dl 0
loc 35
rs 10
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B post-update.js ➔ route 0 28 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/update', '')
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, true)
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(e)
32
  })
33
}
34
35
export default route