You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

thinkjs

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thinkjs - npm Package Compare versions

Comparing version

to
3.0.0-alpha2

const path = require('path');
const cluster = require('cluster');
const helper = require('think-helper');
const thinkLoader = require('./loader.js');
const thinkCluster = require('think-cluster');

@@ -10,2 +9,4 @@ const pm2 = require('think-pm2');

const thinkLoader = require('./loader.js');
/**

@@ -54,3 +55,3 @@ * applition class

srcPath: fileInfo.path,
outPath: think.APP_PATH,
outPath: this.options.APP_PATH,
file: fileInfo.file,

@@ -64,3 +65,5 @@ options: transpiler[1]

}
think.logger.info(`transpile file ${fileInfo.file} success`);
if(think.logger){
think.logger.info(`transpile file ${fileInfo.file} success`);
}
}

@@ -78,4 +81,4 @@ //reload all workers

const instance = new this.options.watcher({
srcPath: path.join(think.ROOT_PATH, 'src'),
diffPath: think.APP_PATH
srcPath: path.join(this.options.ROOT_PATH, 'src'),
diffPath: this.options.APP_PATH
}, fileInfo => this._watcherCallBack(fileInfo));

@@ -122,3 +125,2 @@ instance.watch();

runInMaster(){
this.startWatcher();
const instance = new thinkCluster.Master({

@@ -142,2 +144,3 @@ workers: think.config('workers'),

const instance = new thinkCluster.Worker({
debug: think.env === 'development',
logger: think.logger.error.bind(think.logger),

@@ -184,9 +187,16 @@ processKillTimeout: think.config('processKillTimeout'),

}
//start file watcher
if(cluster.isMaster){
this.startWatcher();
}
const instance = new thinkLoader(this.options);
const argv = this.parseArgv();
instance.loadAll(!!argv.path);
try{
instance.loadAll(!!argv.path);
}catch(e){
think.logger.error(e);
}
if(argv.path){
return this.runInCli(argv.path);
}
if(cluster.isMaster){
}else if(cluster.isMaster){
this.runInMaster();

@@ -193,0 +203,0 @@ }else if(thinkCluster.isAgent()){

@@ -258,14 +258,2 @@ const helper = require('think-helper');

/**
* get model instance
* @param {String} name
* @param {String|Object} config
* @param {String} m
*/
model(name, config, m = this.module){
config = helper.parseAdapterConfig(this.config('model'), config);
//add adapter cache config
config.cache = helper.parseAdapterConfig(this.config('cache'), config.cache);
return think.model(name, config, m);
},
/**
* get controller instance

@@ -272,0 +260,0 @@ * @param {String} name

@@ -195,8 +195,2 @@ const helper = require('think-helper');

/**
* get model instance
*/
model(name, config, m){
return this.ctx.model(name, config, m);
},
/**
* get controller instance

@@ -203,0 +197,0 @@ * @param {String} name

@@ -23,13 +23,2 @@ const assert = require('assert');

/**
* get models
*/
const getModels = function(m){
if(think.app.modules.length){
return helper.extend({}, think.app.models.common, think.app.models[m]);
}else{
return think.app.models;
}
}
module.exports = {

@@ -54,21 +43,2 @@ /**

/**
* get model instance
* @param {String} name
* @param {Object} config
* @param {String} m
*/
model(name, config, m = 'common'){
const cls = getClass('models', name, m);
let commonConfig = helper.parseAdapterConfig(think.config('model'));
config = Object.assign({}, commonConfig, config);
let handle = config.handle;
delete config.handle;
//add models in config, it's need in model when get relation model instance
config.models = getModels(m) || {};
if(cls){
return new cls(name, config);
}
return new handle(name, config);
},
/**
* get service

@@ -75,0 +45,0 @@ */

{
"name": "thinkjs",
"description": "ThinkJS - Use full ES6/7 features to develop web applications, Support TypeScript",
"version": "3.0.0-alpha1",
"version": "3.0.0-alpha2",
"author": {

@@ -55,2 +55,3 @@ "name": "welefen",

"think-meta": "^1.0.1",
"think-mock-http": "^1.0.0",
"think-payload": "^1.0.0",

@@ -62,4 +63,3 @@ "think-pm2": "^1.0.0",

"think-trace": "^1.0.2",
"think-validator": "^1.0.2",
"think-mock-http": "^1.0.0"
"think-validator": "^1.0.2"
},

@@ -66,0 +66,0 @@ "devDependencies": {