summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-01-17 08:06:39 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-01-17 08:06:39 +0900
commitb6ef2fcb04eb65028c7e62cfca667f606d582a7a (patch)
treefc22a3d07b5850f6a46bb1723da8990f103d303b /src
parent[WIP] API testing (diff)
downloadsharkey-b6ef2fcb04eb65028c7e62cfca667f606d582a7a.tar.gz
sharkey-b6ef2fcb04eb65028c7e62cfca667f606d582a7a.tar.bz2
sharkey-b6ef2fcb04eb65028c7e62cfca667f606d582a7a.zip
#31
Diffstat (limited to 'src')
-rw-r--r--src/config.ts18
-rw-r--r--src/globals.d.ts11
-rw-r--r--src/server.ts2
3 files changed, 10 insertions, 21 deletions
diff --git a/src/config.ts b/src/config.ts
index 7c6ecaab25..916aaab580 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -62,12 +62,10 @@ interface Mixin {
export type IConfig = ISource & Mixin;
-/**
- * 設定を取得します
- * @param {string} path 設定ファイルのパス
- * @return {IConfig} 設定
- */
-export default (path: string) => {
+export default load();
+
+function load() {
+ const path = (global as any).MISSKEY_CONFIG_PATH ? (global as any).MISSKEY_CONFIG_PATH : `${__dirname}/../.config/config.yml`;
const config = yaml.safeLoad(fs.readFileSync(path, 'utf8')) as ISource;
const mixin: Mixin = {} as Mixin;
@@ -90,14 +88,14 @@ export default (path: string) => {
mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`;
mixin.drive_url = `${mixin.secondary_scheme}://file.${mixin.secondary_host}`;
- return Object.assign(config || {}, mixin) as IConfig;
-};
+ return Object.assign(config, mixin);
+}
-function normalizeUrl(url: string): string {
+function normalizeUrl(url: string) {
return url[url.length - 1] === '/' ? url.substr(0, url.length - 1) : url;
}
-function urlError(url: string): void {
+function urlError(url: string) {
console.error(`「${url}」は、正しいURLではありません。先頭に http:// または https:// をつけ忘れてないかなど確認してください。`);
process.exit();
}
diff --git a/src/globals.d.ts b/src/globals.d.ts
deleted file mode 100644
index 0af8362122..0000000000
--- a/src/globals.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import * as mongodb from 'mongodb';
-import { IConfig } from './config';
-
-declare var config: IConfig;
-
-declare module NodeJS {
- interface Global {
- config: IConfig;
- db: mongodb.Db;
- }
-}
diff --git a/src/server.ts b/src/server.ts
index bff4b86bce..1a7d8e59b0 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -8,6 +8,8 @@ import * as https from 'https';
import * as express from 'express';
import vhost = require('vhost');
+import config from './config';
+
/**
* Init app
*/