Welcome! Log In Create A New Profile


[nginx-announce] njs-0.7.7

Posted by Dmitry Volyntsev 
Dmitry Volyntsev
[nginx-announce] njs-0.7.7
August 30, 2022 07:04PM

I'm glad to announce a new release of NGINX JavaScript module (njs).

Notable new features:
- advances fs API:
New API allows to open a file and read from and write to at
specified location without reading the whole file.

import fs from 'fs';

async function modifying_large_file() {
let fh = await fs.promises.open('/my/path');

let buf = Buffer.alloc(4);

await fh.read(buf, 0, 4, 64);

console.log(`read ${buf.toString('hex')}`);

// modify part
buf[0] = buf[0] ^ buf[3];

await fh.write(buf, 0, 4, 64);

console.log(`written ${buf.toString('hex')}`);

await fh.close();

Learn more about njs:

- Overview and introduction: https://nginx.org/en/docs/njs/
- NGINX JavaScript in Your Web Server Configuration:
- Extending NGINX with Custom Code: https://youtu.be/0CVhq4AUU7M
- Using node modules with njs:
- Writing njs code using TypeScript definition files:

Feel free to try it and give us feedback on:

- Github: https://github.com/nginx/njs/issues
- Mailing list: https://mailman.nginx.org/mailman/listinfo/nginx-devel

Additional examples and howtos can be found here:

- Github: https://github.com/nginx/njs-examples

Changes with njs 0.7.7 30 Aug 2022

nginx modules:

*) Feature: the number of nginx configuration contexts where
js directives can be specified is extended.

HTTP: js_import, js_path, js_set and js_var are allowed
in server and location contexts. js_content, js_body_filter
and js_header_filter are allowed in 'if' context.

Stream: js_import, js_path, js_set and js_var are allowed
in server context.

*) Feature: added r.internal property.

*) Bugfix: fixed reading response body in fetch API.

*) Bugfix: fixed "js_fetch_timeout" in stream module.

*) Bugfix: fixed socket leak with 0 fetch timeout.


*) Feature: extended "fs" module. Added fs.openSync(),
fs.promises.open(), fs.fstatSync(), fs.readSync(),

The following properties of FileHandle are implemented:
fd, read(), stat(), write(), close().

*) Bugfix: fixed parseInt(), parseFloat(), Symbol.for()
with no arguments.
nginx-announce mailing list -- nginx-announce@nginx.org
To unsubscribe send an email to nginx-announce-leave@nginx.org
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 466 on July 09, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready