Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.
Node 16+
Download the latest release package, extract it, and start developing. To run the website, enable TypeScript compilation and execute node ./index
.
Captcha, Consistent, Crypto, Db (MySQL), Dns (DNSPod, Alibaba Cloud), Fs, Kv (Redis), Net, Scan, Session, Sql, Ssh (Shell, Sftp), Text, Time, Ws, Zlib.
Following the principle of "ready-to-use", this package includes commonly used libraries in a unified style.
By calling the Core.sendRestart method, you can smoothly achieve alternating hot updates between old and new code without interrupting any existing business or connections.
Create a multi-process model based on the number of CPU cores to fully utilize the multi-core CPU.
If different sites in the same process connect to the same server, such as db, kv, etc., they share the same connection pool, maximizing efficiency and reducing overhead.
const res = await lNet.open('https://xxx/test').post().data({ 'a': '1', 'b': '2' }).request();
It can also be used like this:
const res = await lNet.get('https://xxx/test');
You can set custom parsing results:
const res = await lNet.get('https://xxx/test', {
'hosts': {
'xxx': '111.111.111.111'
}
});
You can also choose other local network cards to access:
const res = await lNet.get('https://xxx/test', {
'local': '123.123.123.123'
});
It also has a complete cookie manager, which can easily obtain and store cookies anywhere. When sending a request, the system will select the domain and path based on the cookie settings. If Set-Cookie has an illegal cross-domain setting, it will be discarded and not recorded, just like a real browser.
const res1 = await lNet.get('https://xxx1.xxx/test1', { 'cookie': cookie });
const res2 = await lNet.get('https://xxx2.xxx/test2', { 'cookie': cookie });
Note: The net library supports both options and open chain operations. For example, await lNet.open('xxx').follow().timeout(60).save(this._config.const.rootPath + 'doc/test.txt').request();
With a large number of useful interfaces, you can easily filter the data you need from the database:
const ls = Order.where<Order>(this, db, {
'state': '1'
}).by('id', 'DESC').page(10, 1);
const list = await ls.all();
const count = await ls.count();
const total = await ls.total();
Get a user:
const user = await User.select<User>(this, db, ['id', 'user']).filter([
['time_add', '>=', '1583405134']
]).first();
Use the _checkXInput method to perform XSRF detection and prevent malicious access.
With the help of the Scan library, it's easy to implement scan login.
Achieve reverse proxy functionality effortlessly by utilizing the rproxy method from the net library, combined with route parameters.
let str: string = Core.random(16, Core.RANDOM_N)
Captcha.get(400, 100).getBuffer();
const userList = await User.where<User>(this, db, [
['state', '!=', '0'],
{
'type': ['1', '2', '3'],
'is_lock': '0'
}
]).all();
Note: All database operations have been protected against injection attacks.
sql.select(['SUM(user.age) age'], 'order').leftJoin('user', {'order.user_id': lSql.column('user.id')});
The output will be:
SELECT SUM(`test_user`.`age`) AS `age` FROM `test_order` LEFT JOIN `test_user` ON `test_order`.`user_id` = `test_user`.`id`
It's so easy to write!
await this._loadLocale(this._get['lang'], 'test');
return this._l('copy');
Based on the different values of lang, the output will be: Copy, 复制, 複製, コピー, etc., configured in the /data/locale/ directory.
Directly validate submitted data based on strings, numbers, comparisons, and even regular expressions. It's convenient!
{
'he': ['require', [0, 'The he param does not exist.']],
'num': ['> 10', [0, 'The num param must > 10.']],
'reg': ['/^[A-CX-Z5-7]+$/', [0, 'The reg param is incorrect.']],
'arr': [['a', 'x', 'hehe'], [0, 'The arr param is incorrect.']]
}
See: /test/ctr-checkinput
You can visit /test/ to see more examples.
This library is published under Apache-2.0 license.