njs-0.4.0

Dmitry Volyntsev xeioex at nginx.com
Thu Apr 23 16:10:38 UTC 2020


Hello,

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

This release focuses on extending http and stream modules.

Notable new features:
- js_import directive.
: nginx.conf:
:   js_import foo.js;
:   js_import lib from path/file.js;
: 
:   location / {
:       js_content foo.bar;
:   }
:
: foo.js:
:   function bar(r) {
:       r.return(200);
:   }
:
:   export default {bar};

- multi-value headers support in r.headersOut:
: foo.js:
:   function content(r) {
:        r.headersOut[‘Set-Cookie’] = [
:               ‘foo=111; Max-Age=3600; path=/’,
:               ‘bar=qqq; Max-Age=86400; path=/’
:        ];
:        
:        r.return(200);
:   }

You can learn more about njs:

- Overview and introduction: http://nginx.org/en/docs/njs/
- Presentation: https://youtu.be/Jc_L6UffFOs
- Using node modules with njs: http://nginx.org/en/docs/njs/node_modules.html

Feel free to try it and give us feedback on:

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

Changes with njs 0.4.0                                      23 Apr 2020

    nginx modules:

    *) Feature: added js_import directive.

    *) Feature: added support for multi-value headers in r.headersOut.

    *) Improvement: iteration over r.headersOut with special headers.

    *) Improvement: iteration over r.headersOut with duplicates.

    *) Change: r.responseBody property handler now returns “undefined”
       instead of throwing an exception if response body is not available.

    Core:

    *) Feature: added script arguments support in CLI.

    *) Feature: converting externals values to native js objects.

    *) Bugfix: fixed NULL-pointer dereference in “__proto__” property
       handler.

    *) Bugfix: fixed handling of no-newline at the end of the script.

    *) Bugfix: fixed RegExp() constructor with empty pattern and
       non-empty flags.

    *) Bugfix: fixed String.prototype.replace() when function
       returns non-string.

    *) Bugfix: fixed reading of pseudofiles in “fs”.


More information about the nginx mailing list