forked from visnup/npm-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
117 lines (98 loc) · 2.94 KB
/
config.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
exports.port = 15443
exports.host = 'localhost'
exports.httpPort = 15080
exports.elasticsearch = {
url: 'http://localhost:9200/npm',
pageSize: 20
}
exports.cluster = { size : require("os").cpus().length }
// redis auth
exports.redis = { host: '127.0.0.1', port: 6379 }
exports.registryCouch = "https://aws-west-6.skimdb.internal.npmjs.com/"
// npm config settings
exports.npm =
{ loglevel: "warn"
, registry: "http://registry.npmjs.org/"
, "strict-ssl": false
, _auth: ''
, username: ''
, _password: ''
}
// bunyan config
exports.log =
{ name: 'npm-www'
, level: 'trace'
}
exports.package = require('./package.json')
exports.contributors = require('fs').readFileSync('AUTHORS', 'utf8')
exports.errorPage = { debug: true }
exports.debug = true
// probably don't need to change these too often.
// extra fields we hang on the profile.
// format: [title, display template, url test]
// if it doesn't have a url test, then urls are not allowed.
// The actual value is escaped, so no markup is allowed ever.
exports.profileFields =
{ fullname: [ 'Full Name', '%s' ]
, email: [ 'Email', '<a href="mailto:%s">%s</a>', function (u) {
return u.protocol === 'mailto:'
} ]
, github: [ 'Github', '<a rel="me" href="https://github.com/%s">%s</a>',
hostmatch(/^github.com$/) ]
, twitter: [ 'Twitter', '<a rel="me" href="https://twitter.com/%s">@%s</a>',
hostmatch(/^twitter.com$/) ]
, appdotnet: [ 'App.net', '<a rel="me" href="https://alpha.app.net/%s">%s</a>',
hostmatch(/app.net$/) ]
, homepage: [ 'Homepage', '<a rel="me" href="%s">%s</a>',
hostmatch(/[^\.]+\.[^\.]+$/) ]
, freenode: [ 'IRC Handle', '%s' ]
}
function hostmatch (m) { return function (u) {
return u.host && u.host.match(m)
} }
exports.emailFrom = '"The npm Website Robot" <[email protected]>'
// For development only!
// Don't send 304s for templar (still does for styl and some others)
// npm config set npm-www:nocache 1
exports.nocache = process.env.npm_package_config_nocache === '1'
exports.templateOptions = {
cache: !exports.nocache
}
/*****************/
/* don't delete! */
/*****************/
var env = process.env.NODE_ENV
var admin
if (env === 'production') {
admin = require('./config.admin.js')
} else try {
if (env !== 'dev') {
admin = require('./config.admin.js')
} else {
admin = require('./config.dev.js')
}
} catch (er) {
console.error('Warning: No admin configurations. Not suitable for production use.')
admin = {}
}
exports.metrics = {
collectors: [ 'metrics.internal.npmjs.com:8876' ],
prefix: 'npm-www'
}
Object.keys(admin).forEach(function (k) {
if (k === 'redisAuth') {
exports.redis.auth = admin[k]
} else if (k === 'redis') {
exports.redis.host = admin.redis.host;
exports.redis.port = admin.redis.port;
}
exports[k] = admin[k]
})
if (module === require.main) {
// just show the configs
if (process.argv[2])
console.log(exports[process.argv[2]])
else
console.log(exports)
process.exit(0)
}