Completed
Pull Request — master (#66)
by
unknown
02:04
created

src/server/routes/get-structure.js   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 30
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A get-structure.js ➔ route 0 17 2
1
import fs from 'fs-extra'
2
import path from 'path'
3
4
import {
5
	Manager,
6
  coreUtils,
7
  config,
8
  Handlebars,
9
  User
0 ignored issues
show
Unused Code introduced by
The variable User seems to be never used. Consider removing it.
Loading history...
10
} from '../../cli'
11
12
var route = function(req, res){
13
  var resHtml = ''
14
15
  var page = path.join(__dirname + '/../views/list-structure.html')
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
16
  if (coreUtils.file.exist(page)) {
17
    resHtml = fs.readFileSync(page, 'utf8')
18
  }
19
  
20
  var structure = Manager.instance.getStructureAndTemplates().structure
21
  structure = JSON.stringify(structure).replace(new RegExp(config.root, 'g'), '')
22
  var template = Handlebars.compile(resHtml, {noEscape: true})
23
  var tmp = template({
24
    config: JSON.stringify(config),
25
    structure: structure
26
  })
27
  return res.send(tmp)
28
}
29
30
export default route
31