[nginx-announce] njs-0.7.0

Dmitry Volyntsev xeioex at nginx.com
Tue Oct 19 16:44:27 UTC 2021


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

This release adds a bunch of long-awaited features.

Notable new features:
- async/await support:
- HTTPS support in Fetch API:
: async function content(r) {
:     let results = await Promise.all([ngx.fetch('https://nginx.org/'),
:                                      ngx.fetch('https://nginx.org/en/')]);
:     r.return(200, JSON.stringify(results, undefined, 4));
: }

- WebCrypto API support:
: async function host_hash(r) {
:     let hash = await crypto.subtle.digest('SHA-512', r.headersIn.host);
:     r.setReturnValue(Buffer.from(hash).toString('hex'));
: }

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:

We are hiring:

If you are a C programmer, passionate about Open Source and you
love what we do, consider the following career opportunity:

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

Changes with njs 0.7.0                                        19 Oct 2021

     nginx modules:

     *) Feature: added HTTPS support for Fetch API.

     *) Feature: added setReturnValue() method.


     *) Feature: introduced Async/Await implementation.

     *) Feature: added WebCrypto API implementation.

     *) Bugfix: fixed copying of closures for declared
        functions. The bug was introduced in 0.6.0.

     *) Bugfix: fixed unhandled promise rejection in handle

     *) Bugfix: fixed Response.headers getter in Fetch API.

More information about the nginx-announce mailing list