Check config on load (#4170)

Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
Aya Morisawa 2019-02-06 22:44:55 +09:00 committed by syuilo
parent 41ba06a5e6
commit 96bc17aa10
19 changed files with 195 additions and 125 deletions

View file

@ -46,7 +46,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
description: instance.description,
langs: instance.langs,
secure: config.https != null,
secure: config.https.isJust(),
machine: os.hostname(),
os: os.platform(),
node: process.version,
@ -83,9 +83,9 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
registration: !instance.disableRegistration,
localTimeLine: !instance.disableLocalTimeline,
globalTimeLine: !instance.disableGlobalTimeline,
elasticsearch: config.elasticsearch ? true : false,
elasticsearch: config.elasticsearch.isJust(),
recaptcha: instance.enableRecaptcha,
objectStorage: config.drive && config.drive.storage === 'minio',
objectStorage: config.drive.storage === 'minio',
twitter: instance.enableTwitterIntegration,
github: instance.enableGithubIntegration,
discord: instance.enableDiscordIntegration,

View file

@ -50,7 +50,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
request({
url: url,
proxy: config.proxy,
proxy: config.proxy.getOrElse(null),
timeout: timeout,
json: true,
followRedirect: true,

View file

@ -23,10 +23,10 @@ module.exports = (server: http.Server) => {
let ev: EventEmitter;
if (config.redis) {
if (config.redis.isJust()) {
// Connect to Redis
const subscriber = redis.createClient(
config.redis.port, config.redis.host);
config.redis.get().port, config.redis.get().host);
subscriber.subscribe('misskey');

View file

@ -96,13 +96,14 @@ app.use(router.routes());
app.use(mount(require('./web')));
function createServer() {
if (config.https) {
const certs: any = {};
for (const k of Object.keys(config.https)) {
certs[k] = fs.readFileSync(config.https[k]);
}
certs['allowHTTP1'] = true;
return http2.createSecureServer(certs, app.callback()) as https.Server;
if (config.https.isJust()) {
const opts = {
key: fs.readFileSync(config.https.get().key),
cert: fs.readFileSync(config.https.get().cert),
...config.https.get().ca.map<any>(path => ({ ca: fs.readFileSync(path) })).getOrElse({}),
allowHTTP1: true
};
return http2.createSecureServer(opts, app.callback()) as https.Server;
} else {
return http.createServer(app.callback());
}

View file

@ -69,7 +69,7 @@ async function fetch(url: string, path: string) {
const req = request({
url: requestUrl,
proxy: config.proxy,
proxy: config.proxy.getOrElse(null),
timeout: 10 * 1000,
headers: {
'User-Agent': config.user_agent

View file

@ -31,7 +31,9 @@ const app = new Koa();
app.use(views(__dirname + '/views', {
extension: 'pug',
options: {
config
config: {
url: config.url
}
}
}));