nginScript is a subset of the JavaScript language that allows implementing location and variable handlers in http and stream. nginScript is created in compliance with ECMAScript 5.1 with some ECMAScript 6 extensions. The compliance is still evolving.
var, if, else, switch, for, for in, while, do while, break, continue, return, try, catch, throw, finally Number and Math properties and methods String methods: fromCharCode, concat, slice, substring, substr, charAt, charCodeAt, indexOf, lastIndexOf, toLowerCase, toUpperCase, trim, search, match, split, replace fromCodePoint, codePointAt, includes, startsWith, endsWith, repeat fromUTF8, toUTF8, fromBytes, toBytes Object: rudimentary Object.create() support without properties list Array methods: isArray, slice, splice, push, pop, unshift, shift, reverse, sort, join, concat, indexOf, lastIndexOf, forEach, some, every, filter, map, reduce, reduceRight includes Function methods: call, apply, bind RegExp methods: test, exec Date methods isFinite, isNaN, parseFloat, parseInt, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent let and const declarations arguments array eval function JSON object Error object setTimeout, setInterval, setImmediate functions .235), exponential (3.35e10), binary (0b0101), octal (0o77), hexadecimal (0x1123) literals nginScript is available in two modules:
Both modules are not built by default, they should be either compiled from the sources or installed as a Linux package.
For Linux, nginScript modules packages can be used:
nginx-module-njs — nginScript dynamic modules nginx-module-njs-dbg — debug symbols for the nginx-module-njs package The repository with nginScript sources can be cloned with the following command: (requires Mercurial client):
hg clone http://hg.nginx.org/njs
Then the modules should be compiled using the --add_module configuration parameter:
./configure --add-module=path-to-njs/nginx
The modules can also be built as dynamic:
./configure --add-dynamic_module=path-to-njs/nginx
Both modules are experimental, caveat emptor applies.
© 2002-2017 Igor Sysoev
© 2011-2017 Nginx, Inc.
Licensed under the BSD License.
https://nginx.org/en/docs/njs_about.html