Comparing version 3.1.1 to 3.1.2
@@ -0,7 +1,6 @@ | ||
import * as _Koa from 'koa' | ||
import * as ThinkCluster from 'think-cluster' | ||
import * as Helper from 'think-helper' | ||
import * as ThinkLogger from 'think-logger3' | ||
import * as _Koa from 'koa'; | ||
import * as Helper from 'think-helper'; | ||
import * as ThinkCluster from 'think-cluster'; | ||
import * as ThinkLogger from 'think-logger3'; | ||
declare namespace ThinkJs { | ||
@@ -16,4 +15,4 @@ | ||
class Controller { | ||
constructor(ctx: Koa); | ||
ctx: Koa; | ||
constructor(ctx: Koa.Context); | ||
ctx: Koa.Context; | ||
assign?(name: string, value: any): any; | ||
@@ -20,0 +19,0 @@ render?(file: string, config: object): Promise<string>; |
@@ -105,5 +105,7 @@ const path = require('path'); | ||
runInMaster(argv) { | ||
const port = argv.port || think.config('port'); | ||
const host = think.config('host'); | ||
const instance = new thinkCluster.Master({ | ||
port: argv.port || think.config('port'), | ||
host: think.config('host'), | ||
port, | ||
host, | ||
sticky: think.config('stickyCluster'), | ||
@@ -118,2 +120,7 @@ getRemoteAddress: socket => { | ||
think.app.emit('appReady'); | ||
think.logger.info(`Server running at http://${host || '127.0.0.1'}:${port}`); | ||
think.logger.info(`ThinkJS version: ${think.version}`); | ||
think.logger.info(`Enviroment: ${think.app.env}`); | ||
think.logger.info(`Workers: ${instance.options.workers}`); | ||
}); | ||
@@ -154,10 +161,2 @@ this.masterInstance = instance; | ||
}); | ||
think.app.once('appReady', () => { | ||
if (!thinkCluster.isFirstWorker()) return; | ||
think.logger.info(`Server running at http://${argv.host || '127.0.0.1'}:${port}`); | ||
think.logger.info(`ThinkJS version: ${think.version}`); | ||
think.logger.info(`Enviroment: ${think.app.env}`); | ||
think.logger.info(`Workers: ${instance.getWorkers()}`); | ||
}); | ||
} | ||
@@ -164,0 +163,0 @@ /** |
@@ -168,2 +168,3 @@ const helper = require('think-helper'); | ||
this[PARAM] = Object.assign({}, this.query); | ||
this.app.emit('filterParam', this[PARAM]); | ||
} | ||
@@ -198,2 +199,3 @@ if (!name) return this[PARAM]; | ||
this[POST] = Object.assign({}, this.request.body && this.request.body.post); | ||
this.app.emit('filterParam', this[POST]); | ||
} | ||
@@ -200,0 +202,0 @@ if (!name) return this[POST]; |
@@ -87,2 +87,11 @@ const getConfigFn = require('think-config').getConfigFn; | ||
/** | ||
* write config to file | ||
* @param {Config} config | ||
*/ | ||
writeConfig(config) { | ||
const configFilepath = path.join(think.ROOT_PATH, `runtime/config`); | ||
helper.mkdir(configFilepath); | ||
fs.writeFileSync(`${configFilepath}/${think.app.env}.json`, JSON.stringify(config, undefined, 2)); | ||
} | ||
/** | ||
* load all data | ||
@@ -96,10 +105,7 @@ */ | ||
const config = think.loader.loadConfig(think.app.env); | ||
const configFilepath = path.join(think.ROOT_PATH, `runtime/config`); | ||
helper.mkdir(configFilepath); | ||
fs.writeFileSync(`${configFilepath}/${think.app.env}.json`, JSON.stringify(config, undefined, 2)); | ||
think.config = getConfigFn(config, think.loader.modules.length > 0); | ||
think.logger = new Logger(helper.parseAdapterConfig(think.config('logger')), true); | ||
if (type !== 'master') { | ||
this.writeConfig(config); | ||
this.loadExtend(); | ||
@@ -106,0 +112,0 @@ this.loadData(); |
{ | ||
"name": "thinkjs", | ||
"description": "ThinkJS - Use full ES6/7 features to develop web applications", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"author": { | ||
@@ -67,2 +67,3 @@ "name": "welefen", | ||
"devDependencies": { | ||
"@types/koa": "^2.0.39", | ||
"ava": "^0.18.0", | ||
@@ -69,0 +70,0 @@ "eslint": "^4.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
216524
1145
8