summaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2019-02-06 22:44:55 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-02-06 22:44:55 +0900
commit96bc17aa1014983d5e6bf8b4c05d898156995a0d (patch)
treefdf7c68bdbf3784988351004127db988d7c40c29 /src/server
parentFix bug (diff)
downloadsharkey-96bc17aa1014983d5e6bf8b4c05d898156995a0d.tar.gz
sharkey-96bc17aa1014983d5e6bf8b4c05d898156995a0d.tar.bz2
sharkey-96bc17aa1014983d5e6bf8b4c05d898156995a0d.zip
Check config on load (#4170)
Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
Diffstat (limited to 'src/server')
-rw-r--r--src/server/api/endpoints/meta.ts6
-rw-r--r--src/server/api/endpoints/users/recommendation.ts2
-rw-r--r--src/server/api/streaming.ts4
-rw-r--r--src/server/index.ts15
-rw-r--r--src/server/proxy/proxy-media.ts2
-rw-r--r--src/server/web/index.ts4
6 files changed, 18 insertions, 15 deletions
diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts
index 91cb095c92..d08d0b0734 100644
--- a/src/server/api/endpoints/meta.ts
+++ b/src/server/api/endpoints/meta.ts
@@ -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,
diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts
index e3a03888b6..d07c4b08f0 100644
--- a/src/server/api/endpoints/users/recommendation.ts
+++ b/src/server/api/endpoints/users/recommendation.ts
@@ -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,
diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts
index f8f3c0ff4a..d70cec03dc 100644
--- a/src/server/api/streaming.ts
+++ b/src/server/api/streaming.ts
@@ -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');
diff --git a/src/server/index.ts b/src/server/index.ts
index 0e1c701050..df252a3575 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -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());
}
diff --git a/src/server/proxy/proxy-media.ts b/src/server/proxy/proxy-media.ts
index 3f234a727d..95491b6141 100644
--- a/src/server/proxy/proxy-media.ts
+++ b/src/server/proxy/proxy-media.ts
@@ -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
diff --git a/src/server/web/index.ts b/src/server/web/index.ts
index 3f2e1ed19f..d8a8d75c7a 100644
--- a/src/server/web/index.ts
+++ b/src/server/web/index.ts
@@ -31,7 +31,9 @@ const app = new Koa();
app.use(views(__dirname + '/views', {
extension: 'pug',
options: {
- config
+ config: {
+ url: config.url
+ }
}
}));