This commit is contained in:
		
							parent
							
								
									0900336232
								
							
						
					
					
						commit
						b6ef2fcb04
					
				
					 4 changed files with 12 additions and 23 deletions
				
			
		|  | @ -36,9 +36,9 @@ if (!fs.existsSync('./.config/config.yml')) { | ||||||
| 	process.exit(); | 	process.exit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | (global as any).MISSKEY_CONFIG_PATH = '.config/config.yml'; | ||||||
| import { IConfig } from './src/config'; | import { IConfig } from './src/config'; | ||||||
| const config = eval(require('typescript').transpile(require('fs').readFileSync('./src/config.ts').toString())) | const config = eval(require('typescript').transpile(require('fs').readFileSync('./src/config.ts').toString())) as IConfig; | ||||||
| 	('.config/config.yml') as IConfig; |  | ||||||
| 
 | 
 | ||||||
| const tsProject = ts.createProject('tsconfig.json'); | const tsProject = ts.createProject('tsconfig.json'); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -62,12 +62,10 @@ interface Mixin { | ||||||
| 
 | 
 | ||||||
| export type IConfig = ISource & Mixin; | export type IConfig = ISource & Mixin; | ||||||
| 
 | 
 | ||||||
| /** | export default load(); | ||||||
|  * 設定を取得します | 
 | ||||||
|  * @param  {string} path 設定ファイルのパス | function load() { | ||||||
|  * @return {IConfig}     設定 | 	const path = (global as any).MISSKEY_CONFIG_PATH ? (global as any).MISSKEY_CONFIG_PATH : `${__dirname}/../.config/config.yml`; | ||||||
|  */ |  | ||||||
| export default (path: string) => { |  | ||||||
| 	const config = yaml.safeLoad(fs.readFileSync(path, 'utf8')) as ISource; | 	const config = yaml.safeLoad(fs.readFileSync(path, 'utf8')) as ISource; | ||||||
| 
 | 
 | ||||||
| 	const mixin: Mixin = {} as Mixin; | 	const mixin: Mixin = {} as Mixin; | ||||||
|  | @ -90,14 +88,14 @@ export default (path: string) => { | ||||||
| 	mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; | 	mixin.dev_url = `${mixin.scheme}://dev.${mixin.host}`; | ||||||
| 	mixin.drive_url = `${mixin.secondary_scheme}://file.${mixin.secondary_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; | 	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:// をつけ忘れてないかなど確認してください。`); | 	console.error(`「${url}」は、正しいURLではありません。先頭に http:// または https:// をつけ忘れてないかなど確認してください。`); | ||||||
| 	process.exit(); | 	process.exit(); | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								src/globals.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								src/globals.d.ts
									
										
									
									
										vendored
									
									
								
							|  | @ -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; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -8,6 +8,8 @@ import * as https from 'https'; | ||||||
| import * as express from 'express'; | import * as express from 'express'; | ||||||
| import vhost = require('vhost'); | import vhost = require('vhost'); | ||||||
| 
 | 
 | ||||||
|  | import config from './config'; | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Init app |  * Init app | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue