
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
web项目骨架, 集成ktool,vlog工具库,集成express,集成dot模板引擎, 集成对redis、mongodb、mysql的直接使用
TODO:
v4版本说明:
先在config中配置好连接参数.
const kc = require('kc');
const redis = kc.redis.init(); //自动处理配置载入,异步初始化转为同步
redis.set('key1','val1', (err) => console.log('done')); //支持redis驱动的所有方法
redis.get('key1', (err, val) => console.log('key1:', err, val));
//自定义的带超时的set方法
redis.setWithTime('bbbb', 'hhhhh', 20, (e, j) => console.log('setWithTime:', e, j));
//通过ktool.promi转为await使用
const val = await ktool.promi(kc.redis.get)('key1'); //要求最新版ktool
//多个redis连接同时使用见lib/redis.test.js
const kc = require('kc');
const mongo = kc.mongo.init(); //自动处理配置载入,异步初始化转为同步
//c后面跟collection名,再后面跟mongo原生驱动(非moogose)的方法,此方法是保证初始化完成的关键
mongo.c('user').insertOne({ 'phone': '12345678901' }, (e, re) => {console.log('re:%j', re.result); });
//pc后面跟collection名则返回promise,pQuery为自定义的query方法,直接使用find返回array(原生驱动返回cursor,需要再toArray,注意query默认只返回20条记录)
const reArr = await mongo.pc('user').pQuery({'phone':'12345678901'});
//自定义aggr方法,因为3.x版本的aggregate不再返回array,这里用自定义的aggr还原为返回array
const pipeline = [
{ '$match': { 'phone': '12345678901' } },
{ '$group': { '_id': '$phone', 'count': { '$sum': 1 } } }
];
const re = await mongo.pc('user').pAggr(pipeline);
console.log('pAggr', re);
//因为mongo驱动的方法均返回promise,也同时支持callback,所以mongo.pc('user').后可以跟所有的原生驱动方法
//自定方法包括query/aggr/logToDb,对应promise为pQuery/pAggr/pLogToDb
//多mongo连接同时支持见lib/mongo.test.js
const kc = require('kc');
const mysql = kc.mysql.init(); //自动处理配置载入,异步初始化转为同步
//c()方法参数为c(clusterNode, clusterSelector, configName),这也是保证初始化完成的关键,不可省略。
//conn.release();已经封装在内,无需再次调用
mysql.c().query('insert into tt1 set phone = "11111111111",name="aabb"');
mysql.c().query('select * from tt1 limit 3', (e, re) => {console.log('re:%j', re); });
//mysql.pc()方法支持await,暂未测试
npm install kc -g
kc init [projectName] [port]
npm i
kc config product.json
product.json放置在config目录下,为标准JSON格式,生成的配置文件密文为config/项目名.js,通过jenkins发布到指定服务端,git上不保存product.json等非default.json文件
process.json配置进程
启动项目,如使用deploy的方式启动,需要pm2新版本
pm2 startOrRestart process.json
kc api apiName
可自动生成新api的框架代码在web/api/apiName.js中
FAQs
kc
The npm package kc receives a total of 27 weekly downloads. As such, kc popularity was classified as not popular.
We found that kc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.