Want to subscribe to topics you're interested in?
Become a Member

Nginx [nginx-announce] njs-0.4.1

Discussion in 'Nginx and PHP-FPM news & discussions' started by eva2000, May 20, 2020.

  1. eva2000

    eva2000 Administrator Staff Member

    May 24, 2014
    Brisbane, Australia
    Local Time:
    12:30 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x

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

    This release extends http module.

    Notable new features:
    - raw headers API:
    With the following request headers:
    : Host: localhost
    : Foo: bar
    : foo: bar2
    All 'foo' headers can be collected with the syntax:
    : r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]);
    the output will be:
    : ['bar', 'bar2']

    - TypeScript API definition:
    : foo.ts:
    : /// <reference path="ngx_http_js_module.d.ts" />
    : function content_handler(r: NginxHTTPRequest)
    : {
    : r.headersOut['content-type'] = 'text/plain';
    : r.return(200, "Hello from TypeScript");
    : }
    : tsc foo.ts --outFile foo.js
    foo.js can be used directly with njs.

    You can learn more about njs:

    - Overview and introduction: http://nginx.org/en/docs/njs/
    - Using node modules with njs: http://nginx.org/en/docs/njs/node_modules.html
    - 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: http://mailman.nginx.org/mailman/listinfo/nginx-devel

    Changes with njs 0.4.1 19 May 2020

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

    *) Feature: introduced raw headers API.

    *) Feature: added TypeScript API description.


    *) Bugfix: fixed Array.prototype.slice() for sparse arrays._______________________________________________
    nginx-announce mailing list

    Continue reading...