-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (51 loc) · 1.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let aero = require('aero')
let bodyParser = require('body-parser')
let chalk = require('chalk')
module.exports = app => {
global.admin = aero(__dirname)
// Disable output for admin interface
admin.verbose = false
// The website we're administering
admin.site = app
app.admin = admin
// Copy certificate from the actual site
admin.security = admin.site.security
admin.certificate = admin.site.certificate
// Copy favicon from the actual site
admin.get('favicon.ico', admin.site.server.routes.GET['favicon.ico'])
admin.on('server started', () => {
const link = `${admin.server.protocol}://localhost:${admin.server.port}`
console.log(`Admin interface ${chalk.dim('started on')} ${chalk.green(link)}.`)
})
admin.use(bodyParser.json())
admin.use((request, response, next) => {
request.globals = {
fileExtensionClass: function(file) {
let extension = file.substr(file.lastIndexOf('.') + 1)
switch(extension) {
case 'js':
return 'fa-code'
case 'jade':
return 'fa-html5'
case 'md':
return 'fa-file-text-o'
case 'json':
return 'fa-gear'
case 'jsonld':
return 'fa-database'
case 'styl':
return 'fa-paint-brush'
case 'sh':
return 'fa-terminal'
case 'key':
case 'cert':
return 'fa-lock'
default:
return 'fa-file-o'
}
}
}
next()
})
return admin.run()
}