docs: change heading levels

This commit is contained in:
Dorian Niemiec 2024-09-07 18:48:32 +02:00
parent 0bbea68cf6
commit 5d4d959cc6
27 changed files with 175 additions and 175 deletions

View file

@ -2,15 +2,15 @@
title: SVR.JS API (.tar.gz mods and server-side JavaScript) title: SVR.JS API (.tar.gz mods and server-side JavaScript)
--- ---
## SVR.JS API (_.tar.gz_ mods and server-side JavaScript) # SVR.JS API (_.tar.gz_ mods and server-side JavaScript)
SVR.JS has its API for both _.tar.gz_ mods and server-side JavaScript that expands its functionality. SVR.JS API extends vanilla Node.JS HTTP API. SVR.JS has its API for both _.tar.gz_ mods and server-side JavaScript that expands its functionality. SVR.JS API extends vanilla Node.JS HTTP API.
### Error handling ## Error handling
When a JavaScript error is thrown outside of event callbacks, SVR.JS will return a 500 error to the client. Inside event callbacks, SVR.JS will simply crash. When a JavaScript error is thrown outside of event callbacks, SVR.JS will return a 500 error to the client. Inside event callbacks, SVR.JS will simply crash.
#### Incorrect Error Handling: ### Incorrect Error Handling:
```js ```js
//XXX WARNING!!! IT WILL CRASH THE SVR.JS!!! //XXX WARNING!!! IT WILL CRASH THE SVR.JS!!!
@ -45,7 +45,7 @@ if (href == "/page.svr") {
Instead, you should handle errors gracefully using _callServerError_ function: Instead, you should handle errors gracefully using _callServerError_ function:
#### Correct Error Handling: ### Correct Error Handling:
```js ```js
//Much better! //Much better!
@ -98,7 +98,7 @@ if (href == "/page.svr") {
By using `callServerError`, you can handle errors effectively and provide appropriate error responses to the client, preventing SVR.JS from crashing due to unhandled exceptions. By using `callServerError`, you can handle errors effectively and provide appropriate error responses to the client, preventing SVR.JS from crashing due to unhandled exceptions.
### Non-proxy API ## Non-proxy API
This API is exposed both to mods and server-side JavaScript. This API also includes proxy requests, which don't use CONNECT method. It's possible to determine, if the request comes from the proxy, by checking if _req.url_ begins with "_http://_" or with "_https://_" (unlike non-proxy requests, for which _req.url_ begins with "_/_") like this: This API is exposed both to mods and server-side JavaScript. This API also includes proxy requests, which don't use CONNECT method. It's possible to determine, if the request comes from the proxy, by checking if _req.url_ begins with "_http://_" or with "_https://_" (unlike non-proxy requests, for which _req.url_ begins with "_/_") like this:
@ -108,7 +108,7 @@ var isProxy = req.url && req.url.match(/^https?:\/\//);
SVR.JS applies mods for request URLs beginning with "_http://_" or with "_https://_" (proxy through GET or POST method, non-proxy requests have request URLs beginning with "_/_") only if _Mod.prototype.proxyCallback_ method is present (not possible with SVR.JS server-side JavaScript). SVR.JS applies mods for request URLs beginning with "_http://_" or with "_https://_" (proxy through GET or POST method, non-proxy requests have request URLs beginning with "_/_") only if _Mod.prototype.proxyCallback_ method is present (not possible with SVR.JS server-side JavaScript).
#### _req_ ### _req_
_req_ object is almost same, as _req_ object in Node.JS _req_ object is almost same, as _req_ object in Node.JS
@ -118,7 +118,7 @@ Differences:
- _req.socket.originalRemoteAddress_ and _req.socket.originalRemotePort_ will contain IP address, from which proxy request came from. - _req.socket.originalRemoteAddress_ and _req.socket.originalRemotePort_ will contain IP address, from which proxy request came from.
- _req.url_ refers to request URL after all processing (URL rewriting too) - _req.url_ refers to request URL after all processing (URL rewriting too)
#### _res_ ### _res_
_res_ object is almost same, as _res_ object in Node.JS _res_ object is almost same, as _res_ object in Node.JS
@ -132,7 +132,7 @@ Differences:
- _res.writeHead_ called multiple times will emit a warning, instead of throwing an error, which could crash SVR.JS. - _res.writeHead_ called multiple times will emit a warning, instead of throwing an error, which could crash SVR.JS.
- Custom headers defined in _config.json_ are set by default. - Custom headers defined in _config.json_ are set by default.
#### _serverconsole.climessage(message)_ ### _serverconsole.climessage(message)_
Parameters: Parameters:
@ -140,7 +140,7 @@ Parameters:
Sends CLI message to server console. Sends CLI message to server console.
#### _serverconsole.reqmessage(message)_ ### _serverconsole.reqmessage(message)_
Parameters: Parameters:
@ -148,7 +148,7 @@ Parameters:
Sends request message to server console. Sends request message to server console.
#### _serverconsole.resmessage(message)_ ### _serverconsole.resmessage(message)_
Parameters: Parameters:
@ -156,7 +156,7 @@ Parameters:
Sends response message to server console. Sends response message to server console.
#### _serverconsole.errmessage(message)_ ### _serverconsole.errmessage(message)_
Parameters: Parameters:
@ -164,7 +164,7 @@ Parameters:
Sends response error message to server console. Sends response error message to server console.
#### _serverconsole.locerrmessage(message)_ ### _serverconsole.locerrmessage(message)_
Parameters: Parameters:
@ -172,7 +172,7 @@ Parameters:
Sends local error message to server console. Sends local error message to server console.
#### _serverconsole.locwarnmessage(message)_ ### _serverconsole.locwarnmessage(message)_
Parameters: Parameters:
@ -180,7 +180,7 @@ Parameters:
Sends local warning message to server console. Sends local warning message to server console.
#### _serverconsole.locmessage(message)_ ### _serverconsole.locmessage(message)_
Parameters: Parameters:
@ -188,7 +188,7 @@ Parameters:
Sends local message to server console. Sends local message to server console.
#### _responseEnd(body)_ ### _responseEnd(body)_
Parameters: Parameters:
@ -196,57 +196,57 @@ Parameters:
Sends response message (along with custom head and foot) specified by _body_ parameter. Sends response message (along with custom head and foot) specified by _body_ parameter.
#### _href_ ### _href_
Path name of resource defined in the request. Alias for _uobject.pathname_. Path name of resource defined in the request. Alias for _uobject.pathname_.
#### _ext_ ### _ext_
Extension of resource defined in the request. Extension of resource defined in the request.
#### _uobject_ ### _uobject_
Parsed _Url_ object created by _url.parse()_ method (includes parsed query string). Parsed _Url_ object created by _url.parse()_ method (includes parsed query string).
SVR.JS 3.3.1 and newer include hostname of the server (3.3.1 to 3.14.x use wrapper over WHATWG URL API; 3.15.0 and newer use custom URL parser), older versions don't. SVR.JS 3.3.1 and newer include hostname of the server (3.3.1 to 3.14.x use wrapper over WHATWG URL API; 3.15.0 and newer use custom URL parser), older versions don't.
#### _search_ ### _search_
Query string of URL. Alias for _uobject.search_ Query string of URL. Alias for _uobject.search_
#### _defaultpage_ ### _defaultpage_
**WARNING! DEPRECATED IN SVR.JS 3.X OR NEWER** **WARNING! DEPRECATED IN SVR.JS 3.X OR NEWER**
In SVR.JS 2.x it was alias for _configJSON.defaultpage_. In SVR.JS 3.x for backward compability it's always "_index.html_". In SVR.JS 2.x it was alias for _configJSON.defaultpage_. In SVR.JS 3.x for backward compability it's always "_index.html_".
#### _users_ ### _users_
**WARNING! DEPRECATED** **WARNING! DEPRECATED**
Alias for _configJSON.users_ Alias for _configJSON.users_
#### _page404_ ### _page404_
Alias for _configJSON.page404_ Alias for _configJSON.page404_
#### _head_ ### _head_
HTML head read from either _.head_ or _head.html_ file. HTML head read from either _.head_ or _head.html_ file.
#### _foot_ ### _foot_
HTML foot read from either _.foot_ or _foot.html_ file. HTML foot read from either _.foot_ or _foot.html_ file.
#### _fd_ ### _fd_
**WARNING! This property has currently no use and it's reserved for new SVR.JS functions.** Currently this property is an empty string. **WARNING! This property has currently no use and it's reserved for new SVR.JS functions.** Currently this property is an empty string.
#### _elseCallback()_ ### _elseCallback()_
Invokes next SVR.JS mod callback, SVR.JS server-side JavaScript callback or main SVR.JS callback. Invokes next SVR.JS mod callback, SVR.JS server-side JavaScript callback or main SVR.JS callback.
#### _configJSON_ ### _configJSON_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
@ -254,7 +254,7 @@ Parsed object of _config.json_ file.
SVR.JS 3.4.0 and newer has _version_ property, that corresponds to server version, and _productName_ property, which always is "SVR.JS". SVR.JS 3.4.0 and newer has _version_ property, that corresponds to server version, and _productName_ property, which always is "SVR.JS".
#### _callServerError(errorCode[, extName][, stack][, ch])_ ### _callServerError(errorCode[, extName][, stack][, ch])_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
@ -267,7 +267,7 @@ Parameters:
Invokes HTTP error code. If it's unavailable, invokes 501 error code. Invokes HTTP error code. If it's unavailable, invokes 501 error code.
#### _getCustomHeaders()_ ### _getCustomHeaders()_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
@ -275,13 +275,13 @@ Returns: _Object_ property contains custom headers.
This methods retrieves custom headers from _config.json_ file. Returned object additionally includes _Server_ header. This methods retrieves custom headers from _config.json_ file. Returned object additionally includes _Server_ header.
#### _origHref_ ### _origHref_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
Original path name before URL rewriting. Original path name before URL rewriting.
#### _redirect(dest[, isTemporary][, keepMethod][, headers])_ ### _redirect(dest[, isTemporary][, keepMethod][, headers])_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
@ -294,7 +294,7 @@ Parameters:
Redirects HTTP client to specific destination. Redirects HTTP client to specific destination.
#### _parsePostData([options], callback)_ ### _parsePostData([options], callback)_
<small>_Added in SVR.JS 3.0.0_</small> <small>_Added in SVR.JS 3.0.0_</small>
@ -308,7 +308,7 @@ Parameters:
A wrapper over _formidable_ library, which is used for parsing request bodies of POST requests. A wrapper over _formidable_ library, which is used for parsing request bodies of POST requests.
#### _authUser_ ### _authUser_
<small>_Added in SVR.JS 3.14.2_</small> <small>_Added in SVR.JS 3.14.2_</small>
@ -356,7 +356,7 @@ function checkIfThereIsA401Rule() {
} }
``` ```
### Proxy API ## Proxy API
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
@ -378,37 +378,37 @@ if (!res.writeHead) {
} }
``` ```
#### _req_ ### _req_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
_req_ object is the same, as _req_ object in Node.JS _req_ object is the same, as _req_ object in Node.JS
#### _socket_ ### _socket_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
_socket_ object is the same, as _socket_ object in Node.JS _socket_ object is the same, as _socket_ object in Node.JS
#### _head_ ### _head_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
_head_ object is the same, as _head_ object in Node.JS _head_ object is the same, as _head_ object in Node.JS
#### _configJSON_ ### _configJSON_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
_See configJSON in non-proxy API_ _See configJSON in non-proxy API_
#### _serverconsole_ ### _serverconsole_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>
_See serverconsole in non-proxy API_ _See serverconsole in non-proxy API_
#### _elseCallback()_ ### _elseCallback()_
<small>_Added in SVR.JS 3.4.21, 3.7.0_</small> <small>_Added in SVR.JS 3.4.21, 3.7.0_</small>

View file

@ -2,15 +2,15 @@
title: SVR.JS API (.js mods) title: SVR.JS API (.js mods)
--- ---
## SVR.JS API (_.js_ mods) # SVR.JS API (_.js_ mods)
SVR.JS has its API for _.js_ mods that expands its functionality. SVR.JS API extends vanilla Node.JS HTTP API. SVR.JS has its API for _.js_ mods that expands its functionality. SVR.JS API extends vanilla Node.JS HTTP API.
### Error handling ## Error handling
When a JavaScript error is thrown outside of event callbacks, SVR.JS will return a 500 error to the client. Inside event callbacks, SVR.JS will simply crash. When a JavaScript error is thrown outside of event callbacks, SVR.JS will return a 500 error to the client. Inside event callbacks, SVR.JS will simply crash.
#### Incorrect Error Handling: ### Incorrect Error Handling:
```js ```js
//XXX WARNING!!! IT WILL CRASH THE SVR.JS!!! //XXX WARNING!!! IT WILL CRASH THE SVR.JS!!!
@ -52,7 +52,7 @@ module.exports.modInfo = {
Instead, you should handle errors gracefully using `res.error` function: Instead, you should handle errors gracefully using `res.error` function:
#### Correct Error Handling: ### Correct Error Handling:
```js ```js
//Much better! //Much better!
@ -103,7 +103,7 @@ module.exports.modInfo = {
By using `res.error`, you can handle errors effectively and provide appropriate error responses to the client, preventing SVR.JS from crashing due to unhandled exceptions. By using `res.error`, you can handle errors effectively and provide appropriate error responses to the client, preventing SVR.JS from crashing due to unhandled exceptions.
### Main callback API (`module.exports`) ## Main callback API (`module.exports`)
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -111,13 +111,13 @@ This API includes proxy requests, which don't use CONNECT method. It's possible
SVR.JS applies mods for request URLs beginning with "_http://_" or with "_https://_" (proxy through GET or POST method, non-proxy requests have request URLs beginning with "_/_") only if _module.exports.proxy_ method is present or if _module.exports.proxySafe_ property is set to `true`. SVR.JS applies mods for request URLs beginning with "_http://_" or with "_https://_" (proxy through GET or POST method, non-proxy requests have request URLs beginning with "_/_") only if _module.exports.proxy_ method is present or if _module.exports.proxySafe_ property is set to `true`.
#### _req_ ### _req_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_req_ object is almost same, as _req_ object in Node.JS _req_ object is almost same, as _req_ object in Node.JS
#### _req.socket.realRemoteAddress_ ### _req.socket.realRemoteAddress_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -125,7 +125,7 @@ A property containing IP address, from which request originally went from, if re
You can specify generic request IP variable using `const reqip = req.socket.realRemoteAddress ? req.socket.realRemoteAddress : req.socket.remoteAddress` You can specify generic request IP variable using `const reqip = req.socket.realRemoteAddress ? req.socket.realRemoteAddress : req.socket.remoteAddress`
#### _req.socket.realRemotePort_ ### _req.socket.realRemotePort_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -133,55 +133,55 @@ A property containing port number, from which request originally went from, if r
You can specify generic request IP variable using `const reqip = req.socket.realRemotePort ? req.socket.realRemotePort : req.socket.remotePort` You can specify generic request IP variable using `const reqip = req.socket.realRemotePort ? req.socket.realRemotePort : req.socket.remotePort`
#### _req.socket.originalRemoteAddress_ ### _req.socket.originalRemoteAddress_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing IP address, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`. A property containing IP address, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`.
#### _req.socket.originalRemotePort_ ### _req.socket.originalRemotePort_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing port number, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`. A property containing port number, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`.
#### _req.url_ ### _req.url_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing request URL after all processing (URL rewriting too). A property containing request URL after all processing (URL rewriting too).
#### _req.parsedURL_ ### _req.parsedURL_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing parsed request URL created by a custom URL parser (compatible with legacy URL parser: `url.parse()`) A property containing parsed request URL created by a custom URL parser (compatible with legacy URL parser: `url.parse()`)
#### _req.originalParsedURL_ ### _req.originalParsedURL_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing parsed request URL (before URL rewriting) created by a custom URL parser (compatible with legacy URL parser: `url.parse()`) A property containing parsed request URL (before URL rewriting) created by a custom URL parser (compatible with legacy URL parser: `url.parse()`)
#### _req.isProxy_ ### _req.isProxy_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property that determines if request is a proxy request or not. A property that determines if request is a proxy request or not.
#### _req.authUser_ ### _req.authUser_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
The name of authenticated HTTP user. If the user wasn't authenticated, the property would be _null_. The name of authenticated HTTP user. If the user wasn't authenticated, the property would be _null_.
#### _res_ ### _res_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_res_ object is almost same, as _res_ object in Node.JS _res_ object is almost same, as _res_ object in Node.JS
#### _res.socket.realRemoteAddress_ ### _res.socket.realRemoteAddress_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -189,7 +189,7 @@ A property containing IP address, from which request originally went from, if re
You can specify generic request IP variable using `const reqip = req.socket.realRemoteAddress ? req.socket.realRemoteAddress : req.socket.remoteAddress` You can specify generic request IP variable using `const reqip = req.socket.realRemoteAddress ? req.socket.realRemoteAddress : req.socket.remoteAddress`
#### _res.socket.realRemotePort_ ### _res.socket.realRemotePort_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -197,19 +197,19 @@ A property containing port number, from which request originally went from, if r
You can specify generic request IP variable using `const reqip = req.socket.realRemotePort ? req.socket.realRemotePort : req.socket.remotePort` You can specify generic request IP variable using `const reqip = req.socket.realRemotePort ? req.socket.realRemotePort : req.socket.remotePort`
#### _res.socket.originalRemoteAddress_ ### _res.socket.originalRemoteAddress_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing IP address, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`. A property containing IP address, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`.
#### _res.socket.originalRemotePort_ ### _res.socket.originalRemotePort_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing port number, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`. A property containing port number, from which proxy request came from. If the request isn't a proxy request, it will be `undefined`.
#### _res.writeHead(statusCode[, statusMessage][, headers])_ ### _res.writeHead(statusCode[, statusMessage][, headers])_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -223,7 +223,7 @@ Returns: _res_ property.
The difference between _res.writeHead_ in Node.JS, and in SVR.JS is that in SVR.JS it writes into server log, doesn't invoke a warning about unused status code string, and if called multiple times will emit a warning, instead of throwing an error, which could crash SVR.JS. The difference between _res.writeHead_ in Node.JS, and in SVR.JS is that in SVR.JS it writes into server log, doesn't invoke a warning about unused status code string, and if called multiple times will emit a warning, instead of throwing an error, which could crash SVR.JS.
#### _res.setHeader(name, value)_ ### _res.setHeader(name, value)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -236,19 +236,19 @@ The difference between _res.setHeader_ in Node.JS, and in SVR.JS is that in SVR.
Custom headers defined in _config.json_ are set by default. Custom headers defined in _config.json_ are set by default.
#### _res.head_ ### _res.head_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
HTML head read from either _.head_ or _head.html_ file. HTML head read from either _.head_ or _head.html_ file.
#### _res.foot_ ### _res.foot_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
HTML foot read from either _.foot_ or _foot.html_ file. HTML foot read from either _.foot_ or _foot.html_ file.
#### _res.responseEnd(body)_ ### _res.responseEnd(body)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -258,7 +258,7 @@ Parameters:
Sends response message (along with custom head and foot) specified by _body_ parameter. Sends response message (along with custom head and foot) specified by _body_ parameter.
#### _res.error(errorCode[, extName][, stack][, ch])_ ### _res.error(errorCode[, extName][, stack][, ch])_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -271,7 +271,7 @@ Parameters:
Invokes HTTP error code. If it's unavailable, invokes 501 error code. Invokes HTTP error code. If it's unavailable, invokes 501 error code.
#### _res.redirect(dest[, isTemporary][, keepMethod][, headers])_ ### _res.redirect(dest[, isTemporary][, keepMethod][, headers])_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -284,13 +284,13 @@ Parameters:
Redirects HTTP client to specific destination. Redirects HTTP client to specific destination.
#### _logFacilities_ ### _logFacilities_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
The log facilities for SVR.JS. The log facilities for SVR.JS.
#### _logFacilities.climessage(message)_ ### _logFacilities.climessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -300,7 +300,7 @@ Parameters:
Sends CLI message to server console. Sends CLI message to server console.
#### _logFacilities.reqmessage(message)_ ### _logFacilities.reqmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -310,7 +310,7 @@ Parameters:
Sends request message to server console. Sends request message to server console.
#### _logFacilities.resmessage(message)_ ### _logFacilities.resmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -320,7 +320,7 @@ Parameters:
Sends response message to server console. Sends response message to server console.
#### _logFacilities.errmessage(message)_ ### _logFacilities.errmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -330,7 +330,7 @@ Parameters:
Sends response error message to server console. Sends response error message to server console.
#### _logFacilities.locerrmessage(message)_ ### _logFacilities.locerrmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -340,7 +340,7 @@ Parameters:
Sends local error message to server console. Sends local error message to server console.
#### _logFacilities.locwarnmessage(message)_ ### _logFacilities.locwarnmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -350,7 +350,7 @@ Parameters:
Sends local warning message to server console. Sends local warning message to server console.
#### _logFacilities.locmessage(message)_ ### _logFacilities.locmessage(message)_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -360,13 +360,13 @@ Parameters:
Sends local message to server console. Sends local message to server console.
#### _config_ ### _config_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
This object contains properties from _config.json_ file. This object contains properties from _config.json_ file.
#### _config.getCustomHeaders()_ ### _config.getCustomHeaders()_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -374,7 +374,7 @@ Returns: _Object_ property contains custom headers.
This methods retrieves custom headers from _config.json_ file. Returned object additionally includes _Server_ header. This methods retrieves custom headers from _config.json_ file. Returned object additionally includes _Server_ header.
#### _config.generateServerString()_ ### _config.generateServerString()_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
@ -382,97 +382,97 @@ Returns: The generated server string.
This methods generated the string which is used to identify a web server (the same string as in the "Server" header). This methods generated the string which is used to identify a web server (the same string as in the "Server" header).
#### _next()_ ### _next()_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
Invokes next SVR.JS mod callback, SVR.JS server-side JavaScript callback or main SVR.JS callback. Invokes next SVR.JS mod callback, SVR.JS server-side JavaScript callback or main SVR.JS callback.
### Proxy callback API (`module.exports.proxy`) ## Proxy callback API (`module.exports.proxy`)
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
#### _req_ ### _req_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_req_ object is the same, as _req_ object in Node.JS _req_ object is the same, as _req_ object in Node.JS
#### _socket_ ### _socket_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_socket_ object is the same, as _socket_ object in Node.JS _socket_ object is the same, as _socket_ object in Node.JS
#### _head_ ### _head_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_head_ object is the same, as _head_ object in Node.JS _head_ object is the same, as _head_ object in Node.JS
#### _logFacilities_ ### _logFacilities_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_See logFacilties in main callback API_ _See logFacilties in main callback API_
#### _config_ ### _config_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_See config in main callback API_ _See config in main callback API_
#### _next()_ ### _next()_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
_See next in main callback API_ _See next in main callback API_
### Global variables (for use in callback APIs) ## Global variables (for use in callback APIs)
#### _process.versions.svrjs_ ### _process.versions.svrjs_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing SVR.JS version. A property containing SVR.JS version.
#### _process.serverConfiguration_ ### _process.serverConfiguration_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containing SVR.JS configuration from _config.json_ file. A property containing SVR.JS configuration from _config.json_ file.
#### _process.dirname_ ### _process.dirname_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containg the SVR.JS installation directory. A property containg the SVR.JS installation directory.
#### _process.filename_ ### _process.filename_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containg the path to the SVR.JS script. A property containg the path to the SVR.JS script.
#### _process.err4xxcounter_ ### _process.err4xxcounter_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containg the count of 4xx HTTP errors. A property containg the count of 4xx HTTP errors.
#### _process.err5xxcounter_ ### _process.err5xxcounter_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containg the count of 5xx HTTP errors. A property containg the count of 5xx HTTP errors.
#### _process.reqcounter_ ### _process.reqcounter_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>
A property containg the count of HTTP requests. A property containg the count of HTTP requests.
#### _process.malformedcounter_ ### _process.malformedcounter_
<small>_Added in SVR.JS 4.0.0_</small> <small>_Added in SVR.JS 4.0.0_</small>

View file

@ -2,11 +2,11 @@
title: CGI/SCGI/JSGI/PHP title: CGI/SCGI/JSGI/PHP
--- ---
### CGI/SCGI/JSGI/PHP # CGI/SCGI/JSGI/PHP
In order to use CGI with SVR.JS, you need to install RedBrick mod. For SCGI you need to install OrangeCircle, while for JSGI you need to install YellowSquare mod. [Download these mods.](https://svrjs.org/mods) In order to use CGI with SVR.JS, you need to install RedBrick mod. For SCGI you need to install OrangeCircle, while for JSGI you need to install YellowSquare mod. [Download these mods.](https://svrjs.org/mods)
#### CGI and PHP via RedBrick ## CGI and PHP via RedBrick
RedBrick supports running CGI programs and PHP files (RedBrick 2.3.0 and newer) in cgi-bin directory. RedBrick 2.5.0 and newer support running CGI programs and PHP files outside cgi-bin directory. You can configure file extensions outside of cgi-bin directory handled by RedBrick in _redbrick-scriptexts.json_ file in SVR.JS installation directory like this: RedBrick supports running CGI programs and PHP files (RedBrick 2.3.0 and newer) in cgi-bin directory. RedBrick 2.5.0 and newer support running CGI programs and PHP files outside cgi-bin directory. You can configure file extensions outside of cgi-bin directory handled by RedBrick in _redbrick-scriptexts.json_ file in SVR.JS installation directory like this:
@ -46,7 +46,7 @@ SVR.JS currently supports PHP-CGI through RedBrick mod. <s>PHP is currently supp
For security reasons, you may disable directory listing for _cgi-bin_ (and also other directories) through _disableDirectoryListing_ or _disableDirectoryListingVHost_ options in SVR.JS configuration. For security reasons, you may disable directory listing for _cgi-bin_ (and also other directories) through _disableDirectoryListing_ or _disableDirectoryListingVHost_ options in SVR.JS configuration.
#### SCGI via OrangeCircle ## SCGI via OrangeCircle
OrangeCircle can be configured in _orangecircle-config.json_ file in SVR.JS install directory like this: OrangeCircle can be configured in _orangecircle-config.json_ file in SVR.JS install directory like this:
@ -60,7 +60,7 @@ OrangeCircle can be configured in _orangecircle-config.json_ file in SVR.JS inst
OrangeCircle 1.0.7 and newer work with web root outside SVR.JS installation directory (older ones need _config.json_ file in web root with valid JSON data; not necessarily related to _config.json_ in SVR.JS installation directory) OrangeCircle 1.0.7 and newer work with web root outside SVR.JS installation directory (older ones need _config.json_ file in web root with valid JSON data; not necessarily related to _config.json_ in SVR.JS installation directory)
#### JSGI via YellowSquare ## JSGI via YellowSquare
YellowSquare supports running JSGI scripts only in jsgi-bin directory. YellowSquare runs JSGI scripts, that are either with _.jsgi_ or _.jsgi.js_ extension. Every change in JSGI application requires a restart of SVR.JS in order to be applied. YellowSquare supports running JSGI scripts only in jsgi-bin directory. YellowSquare runs JSGI scripts, that are either with _.jsgi_ or _.jsgi.js_ extension. Every change in JSGI application requires a restart of SVR.JS in order to be applied.
@ -68,11 +68,11 @@ YellowSquare 1.0.3 and newer work with web root outside SVR.JS installation dire
For security reasons, you may disable directory listing for _jsgi-bin_ (and also other directories) through _disableDirectoryListing_ or _disableDirectoryListingVHost_ options in SVR.JS configuration. For security reasons, you may disable directory listing for _jsgi-bin_ (and also other directories) through _disableDirectoryListing_ or _disableDirectoryListingVHost_ options in SVR.JS configuration.
### FastCGI/PHP-FPM # FastCGI/PHP-FPM
In order to use FastCGI with SVR.JS, you need to install GreenRhombus mod. [Download the mod.](https://svrjs.org/mods) In order to use FastCGI with SVR.JS, you need to install GreenRhombus mod. [Download the mod.](https://svrjs.org/mods)
#### GreenRhombus notes ## GreenRhombus notes
GreenRhombus' path and FastCGI server address can be configured in _greenrhombus-config.json_ file in the SVR.JS install directory. GreenRhombus' path and FastCGI server address can be configured in _greenrhombus-config.json_ file in the SVR.JS install directory.
@ -101,7 +101,7 @@ You can configure file extensions outside of path specified in _greenrhombus-con
[".php"] [".php"]
``` ```
#### PHP-FPM ## PHP-FPM
GreenRhombus supports running PHP files through PHP-FPM. If you want to use GreenRhombus only for PHP-FPM, configure _greenrhombus-config.json_ like this (in this case we're using socket in `/run/php/php8.2-fpm.sock`; you can check it in PHP-FPM configuration file, e.g. `/etc/php/8.2/fpm/pool.d/www.conf`; configure it without _path_ property): GreenRhombus supports running PHP files through PHP-FPM. If you want to use GreenRhombus only for PHP-FPM, configure _greenrhombus-config.json_ like this (in this case we're using socket in `/run/php/php8.2-fpm.sock`; you can check it in PHP-FPM configuration file, e.g. `/etc/php/8.2/fpm/pool.d/www.conf`; configure it without _path_ property):

View file

@ -2,7 +2,7 @@
title: CLI options title: CLI options
--- ---
### CLI options # CLI options
- _-h_, _-?_, _/h_, _/?_ or _--help_ - displays help - _-h_, _-?_, _/h_, _/?_ or _--help_ - displays help
- _--clean_ - cleans up files created by SVR.JS - _--clean_ - cleans up files created by SVR.JS

View file

@ -2,6 +2,6 @@
title: Client-initiated secure renegotiation title: Client-initiated secure renegotiation
--- ---
### Client-initiated secure renegotiation # Client-initiated secure renegotiation
Client-initiated secure renegotiation may pose DoS risks. However, Node.JS (JS runtime on which SVR.JS is running on) has built-in protection against DoS attacks caused by client-initiated secure renegotiation. Such attacks can be detected by looking for _ERR_TLS_SESSION_ATTACK_ errors in server log. Client-initiated secure renegotiation may pose DoS risks. However, Node.JS (JS runtime on which SVR.JS is running on) has built-in protection against DoS attacks caused by client-initiated secure renegotiation. Such attacks can be detected by looking for _ERR_TLS_SESSION_ATTACK_ errors in server log.

View file

@ -2,11 +2,11 @@
title: config.json properties title: config.json properties
--- ---
### _config.json_ properties # _config.json_ properties
The _config.json_ file contains various properties that you can customize to configure SVR.JS according to your specific requirements. Below are the available properties: The _config.json_ file contains various properties that you can customize to configure SVR.JS according to your specific requirements. Below are the available properties:
#### General Configuration ## General Configuration
- _users_ (Array of Objects, SVR.JS 3.0.0 or newer) - _users_ (Array of Objects, SVR.JS 3.0.0 or newer)
- Users list for HTTP authentication. Use _svrpasswd_ tool to add, modify or delete users. - Users list for HTTP authentication. Use _svrpasswd_ tool to add, modify or delete users.
@ -24,7 +24,7 @@ The _config.json_ file contains various properties that you can customize to con
- _spubport_ (Number) - _spubport_ (Number)
- Public HTTPS port for SVR.JS to display. It is also used in HTTP to HTTPS redirect. - Public HTTPS port for SVR.JS to display. It is also used in HTTP to HTTPS redirect.
#### SSL Configuration ## SSL Configuration
- _secure_ (Boolean, SVR.JS 3.0.0 or newer) - _secure_ (Boolean, SVR.JS 3.0.0 or newer)
- Option to enable HTTPS. - Option to enable HTTPS.
@ -52,14 +52,14 @@ The _config.json_ file contains various properties that you can customize to con
- _tlsMaxVersion_ (String, SVR.JS 3.14.0 or newer) - _tlsMaxVersion_ (String, SVR.JS 3.14.0 or newer)
- Maximum TLS version, it can be `TLSv1.3`, `TLSv1.2`, `TLSv1.1`, or `TLSv1`. - Maximum TLS version, it can be `TLSv1.3`, `TLSv1.2`, `TLSv1.1`, or `TLSv1`.
#### Domain and Redirect Configuration ## Domain and Redirect Configuration
- _domain_ (String) - _domain_ (String)
- Domain for SVR.JS to display. (In SVR.JS 2.x, it was _domian_) - Domain for SVR.JS to display. (In SVR.JS 2.x, it was _domian_)
- _wwwredirect_ (Boolean) - _wwwredirect_ (Boolean)
- Option to enable redirects to domain name that begins with "www.". You need to first set _domain_ property in order for this option to have effect. This property didn't work in SVR.JS versions from 3.3.0 to 3.14.4 - Option to enable redirects to domain name that begins with "www.". You need to first set _domain_ property in order for this option to have effect. This property didn't work in SVR.JS versions from 3.3.0 to 3.14.4
#### Error Pages and Logging Configuration ## Error Pages and Logging Configuration
- _page404_ (String) - _page404_ (String)
- Path to a custom 404 error page (after pages defined in _errorPages_ property). - Path to a custom 404 error page (after pages defined in _errorPages_ property).
@ -74,7 +74,7 @@ The _config.json_ file contains various properties that you can customize to con
- _enableLogging_ (Boolean) - _enableLogging_ (Boolean)
- Option to enable saving logs to a log file. - Option to enable saving logs to a log file.
#### HTTP Configuration ## HTTP Configuration
- _enableCompression_ (Boolean, SVR.JS 3.0.0 or newer) - _enableCompression_ (Boolean, SVR.JS 3.0.0 or newer)
- Option to enable HTTP compression. - Option to enable HTTP compression.
@ -115,7 +115,7 @@ The _config.json_ file contains various properties that you can customize to con
- _enableConnectProtocol_: Option to enable the "Extended Connect Protocol" defined by RFC 8441 (Number, SVR.JS 3.14.0 or newer). - _enableConnectProtocol_: Option to enable the "Extended Connect Protocol" defined by RFC 8441 (Number, SVR.JS 3.14.0 or newer).
- _customSettings_: Additional settings not implemented yet in Node.JS and its underlying libraries. Object key defines the numeric value of the settings type (as defined in the "HTTP/2 SETTINGS" registry established by RFC 7540). Object values define actual numeric value of the settings. Settings types should be greater than 6 and less than 2<sup>16</sup>-1. Values should be in range from 0 to 2<sup>32</sup>-1. Currently you can specify up to 10 custom settings (Object, SVR.JS 3.14.0 or newer). - _customSettings_: Additional settings not implemented yet in Node.JS and its underlying libraries. Object key defines the numeric value of the settings type (as defined in the "HTTP/2 SETTINGS" registry established by RFC 7540). Object values define actual numeric value of the settings. Settings types should be greater than 6 and less than 2<sup>16</sup>-1. Values should be in range from 0 to 2<sup>32</sup>-1. Currently you can specify up to 10 custom settings (Object, SVR.JS 3.14.0 or newer).
#### Security Configuration ## Security Configuration
- _blacklist_ (Array of Strings) - _blacklist_ (Array of Strings)
- Block list of IP addresses and CIDR ranges. - Block list of IP addresses and CIDR ranges.
@ -130,7 +130,7 @@ The _config.json_ file contains various properties that you can customize to con
- _exposeModsInErrorPages_ (Boolean, SVR.JS 3.4.29, 3.9.1 or newer) - _exposeModsInErrorPages_ (Boolean, SVR.JS 3.4.29, 3.9.1 or newer)
- Option to expose SVR.JS mod information through default error pages (for example in _SVR.JS RedBrick/2.4.2 on forum.svrjs.org_ signature). Mod information is never exposed through _Server_ header (just SVR.JS information). - Option to expose SVR.JS mod information through default error pages (for example in _SVR.JS RedBrick/2.4.2 on forum.svrjs.org_ signature). Mod information is never exposed through _Server_ header (just SVR.JS information).
#### Virtual Host Configuration ## Virtual Host Configuration
- _enableDirectoryListingVHost_ (Array of Objects; SVR.JS 3.8.0 or newer) - _enableDirectoryListingVHost_ (Array of Objects; SVR.JS 3.8.0 or newer)
- Array containing options to enable directory listings for specific virtual hosts. - Array containing options to enable directory listings for specific virtual hosts.
@ -153,7 +153,7 @@ The _config.json_ file contains various properties that you can customize to con
- _allowPostfixDoubleSlashes_ (Boolean, SVR.JS 3.14.4 or newer) - _allowPostfixDoubleSlashes_ (Boolean, SVR.JS 3.14.4 or newer)
- Option to allow double slashes, when inserting web root postfixes. If set to `false`, double slashes are removed by postfix insertion function. It may create issues with double slash URLs not having prefixes. - Option to allow double slashes, when inserting web root postfixes. If set to `false`, double slashes are removed by postfix insertion function. It may create issues with double slash URLs not having prefixes.
#### Miscellaneous Configuration ## Miscellaneous Configuration
- _rewriteMap_ (Array of Objects, SVR.JS 3.0.0 or newer) - _rewriteMap_ (Array of Objects, SVR.JS 3.0.0 or newer)
- Map for URL rewriting engine. Entries of the array are URL rewrite rules. - Map for URL rewriting engine. Entries of the array are URL rewrite rules.
@ -188,7 +188,7 @@ The _config.json_ file contains various properties that you can customize to con
- _optOutOfStatisticsServer_ (Boolean, SVR.JS 3.15.6 or newer) - _optOutOfStatisticsServer_ (Boolean, SVR.JS 3.15.6 or newer)
- Option to opt out of sending data to the statistics server. You can use this option to increase the privacy of SVR.JS. - Option to opt out of sending data to the statistics server. You can use this option to increase the privacy of SVR.JS.
#### Deprecated and Removed Properties ## Deprecated and Removed Properties
The following properties are deprecated or removed in newer versions of SVR.JS, and modifying them might not have any effect on the server: The following properties are deprecated or removed in newer versions of SVR.JS, and modifying them might not have any effect on the server:
@ -197,7 +197,7 @@ The following properties are deprecated or removed in newer versions of SVR.JS,
- _version_ (String, removed in SVR.JS 3.4.0, **DON'T CHANGE**) - _version_ (String, removed in SVR.JS 3.4.0, **DON'T CHANGE**)
- SVR.JS version (This property is no longer used and should not be modified.) - SVR.JS version (This property is no longer used and should not be modified.)
#### Example Configuration ## Example Configuration
Here's an example _config.json_ file illustrating some of the available properties: Here's an example _config.json_ file illustrating some of the available properties:

View file

@ -2,7 +2,7 @@
title: Custom error pages title: Custom error pages
--- ---
### Custom error pages # Custom error pages
You can configure SVR.JS to serve custom error pages by adding _.&lt;errorcode&gt;_ (SVR.JS 3.0.0 or newer) or _&lt;errorcode&gt;.html_ pages. For the 404 error, you can specify it by changing the _page404_ property in _config.json_. From SVR.JS 3.8.0 onwards, you can use _errorPages_ property in _config.json_ to specify path to each custom error page. You can configure SVR.JS to serve custom error pages by adding _.&lt;errorcode&gt;_ (SVR.JS 3.0.0 or newer) or _&lt;errorcode&gt;.html_ pages. For the 404 error, you can specify it by changing the _page404_ property in _config.json_. From SVR.JS 3.8.0 onwards, you can use _errorPages_ property in _config.json_ to specify path to each custom error page.

View file

@ -2,13 +2,13 @@
title: Environment variables title: Environment variables
--- ---
### Environment variables # Environment variables
#### SVR.JS 3.12.0 and newer ## SVR.JS 3.12.0 and newer
You can configure environment variables by configuring _environmentVariables_ property in _config.json_. You can configure environment variables by configuring _environmentVariables_ property in _config.json_.
#### Older SVR.JS versions ## Older SVR.JS versions
SVR.JS seamlessly passes through externally set environment variables to mods and server-side JavaScript, allowing you to customize and control your application's behavior based on these variables. SVR.JS seamlessly passes through externally set environment variables to mods and server-side JavaScript, allowing you to customize and control your application's behavior based on these variables.

View file

@ -2,7 +2,7 @@
title: Forward proxy notes title: Forward proxy notes
--- ---
### Forward proxy notes # Forward proxy notes
In order to use SVR.JS as a forward proxy, you need to install forward-proxy-mod SVR.JS mod. [Download this mod.](https://svrjs.org/mods) In order to use SVR.JS as a forward proxy, you need to install forward-proxy-mod SVR.JS mod. [Download this mod.](https://svrjs.org/mods)

View file

@ -2,7 +2,7 @@
title: HTTP authentication title: HTTP authentication
--- ---
### HTTP authentication # HTTP authentication
You can add HTTP basic authentication by including a 401 code (with _scode_ property set to 401) entry in the _nonStandardCodes_ property of _config.json_. To enable HTTP basic authentication, you need to specify the URL you want to restrict in the _url_ or _regex_ property of the entry. Additionally, you can set the authentication realm in the _realm_ property. If the realm is not specified, the default realm is "_SVR.JS HTTP Basic Authorization_". The encoding used for authentication will always be UTF-8. You can add HTTP basic authentication by including a 401 code (with _scode_ property set to 401) entry in the _nonStandardCodes_ property of _config.json_. To enable HTTP basic authentication, you need to specify the URL you want to restrict in the _url_ or _regex_ property of the entry. Additionally, you can set the authentication realm in the _realm_ property. If the realm is not specified, the default realm is "_SVR.JS HTTP Basic Authorization_". The encoding used for authentication will always be UTF-8.

View file

@ -2,7 +2,7 @@
title: Page customization title: Page customization
--- ---
### Page customization # Page customization
You can easily customize the appearance of pages served by SVR.JS by adding custom head and foot sections. These sections can be linked to every _.html_ file served by SVR.JS. You can easily customize the appearance of pages served by SVR.JS by adding custom head and foot sections. These sections can be linked to every _.html_ file served by SVR.JS.

View file

@ -2,7 +2,7 @@
title: Reverse proxy configuration title: Reverse proxy configuration
--- ---
### Reverse proxy configuration # Reverse proxy configuration
In order to use SVR.JS as a reverse proxy, you need to install reverse-proxy-mod SVR.JS mod. [Download this mod.](https://svrjs.org/mods) In order to use SVR.JS as a reverse proxy, you need to install reverse-proxy-mod SVR.JS mod. [Download this mod.](https://svrjs.org/mods)

View file

@ -2,7 +2,7 @@
title: User management title: User management
--- ---
### User management # User management
You can manage users for HTTP authentication in SVR.JS by using _svrpasswd.js_ tool (SVR.JS 3.0.0 or newer). Usage is `node svrpasswd.js [-h] [--help] [-?] [/h] [/?] [-x] [-a|--add|-d|--delete] <username>`. Command-line options: You can manage users for HTTP authentication in SVR.JS by using _svrpasswd.js_ tool (SVR.JS 3.0.0 or newer). Usage is `node svrpasswd.js [-h] [--help] [-?] [/h] [/?] [-x] [-a|--add|-d|--delete] <username>`. Command-line options:

View file

@ -2,7 +2,7 @@
title: Virtual hosts title: Virtual hosts
--- ---
### Virtual hosts # Virtual hosts
When you're not planning to use SVR.JS server-side JavaScript or SVR.JS mods implementing individual web applications and plan to use SVR.JS similarly to Apache, nginx or IIS (static-only, PHP, CGI or JSGI), you can use virtual host-like functionality (name-based; IP-based from SVR.JS 3.14.1 and newer) with SVR.JS 3.8.0 or newer. When you're not planning to use SVR.JS server-side JavaScript or SVR.JS mods implementing individual web applications and plan to use SVR.JS similarly to Apache, nginx or IIS (static-only, PHP, CGI or JSGI), you can use virtual host-like functionality (name-based; IP-based from SVR.JS 3.14.1 and newer) with SVR.JS 3.8.0 or newer.

View file

@ -2,9 +2,9 @@
title: Features title: Features
--- ---
### Features # Features
#### Static file handling ## Static file handling
- Static file serving (even above 2GB) - Static file serving (even above 2GB)
- Directory listing serving - Directory listing serving
@ -12,7 +12,7 @@ title: Features
- Content-Range support (for non-HTML static files; also for HTML files from SVR.JS 3.15.1) - Content-Range support (for non-HTML static files; also for HTML files from SVR.JS 3.15.1)
- Serving from web root different than SVR.JS installation directory - Serving from web root different than SVR.JS installation directory
#### Security ## Security
- HTTPS support - HTTPS support
- HTTP/2 support - HTTP/2 support
@ -21,7 +21,7 @@ title: Features
- Ability to hide server version - Ability to hide server version
- OCSP stapling support (from SVR.JS 3.4.9) - OCSP stapling support (from SVR.JS 3.4.9)
#### Configuration and customization ## Configuration and customization
- Configurability via _config.json_ file - Configurability via _config.json_ file
- Expandability via server-side JavaScript and mods - Expandability via server-side JavaScript and mods
@ -29,7 +29,7 @@ title: Features
- URL rewriting engine - URL rewriting engine
- Event driven architecture powered by Node.JS, along with clustering. - Event driven architecture powered by Node.JS, along with clustering.
#### Compression and content delivery ## Compression and content delivery
- Brotli, gzip and Deflate HTTP compression (Brotli supported since SVR.JS 3.4.11) - Brotli, gzip and Deflate HTTP compression (Brotli supported since SVR.JS 3.4.11)
- SNI (Server Name Indication) support - SNI (Server Name Indication) support
@ -37,18 +37,18 @@ title: Features
- Reverse proxy functionality (requires reverse-proxy-mod SVR.JS mod) - Reverse proxy functionality (requires reverse-proxy-mod SVR.JS mod)
- Forward proxy functionality (requires forward-proxy-mod SVR.JS mod) - Forward proxy functionality (requires forward-proxy-mod SVR.JS mod)
#### Authentication and access control ## Authentication and access control
- HTTP basic authentication - HTTP basic authentication
#### Gateway interfaces ## Gateway interfaces
- CGI (Common Gateway Interface) support (requires RedBrick mod) - CGI (Common Gateway Interface) support (requires RedBrick mod)
- SCGI (Simple Common Gateway Interface) support (requires OrangeCircle mod) - SCGI (Simple Common Gateway Interface) support (requires OrangeCircle mod)
- JSGI (JavaScript Gateway Interface) support (requires YellowSquare mod) - JSGI (JavaScript Gateway Interface) support (requires YellowSquare mod)
- PHP support (PHP-CGI with RedBrick mod or PHP-FPM with GreenRhombus mod) - PHP support (PHP-CGI with RedBrick mod or PHP-FPM with GreenRhombus mod)
#### Additional functionality ## Additional functionality
- Logging - Logging
- Ability to display IP addresses, from which originally request was made (from reverse proxies; via X-Forwarded-For) - Ability to display IP addresses, from which originally request was made (from reverse proxies; via X-Forwarded-For)

View file

@ -2,9 +2,9 @@
title: Installation title: Installation
--- ---
### Installation # Installation
#### Using SVR.JS installer (installer packages made in April 5, 2024 and later; GNU/Linux only) ## Using SVR.JS installer (installer packages made in April 5, 2024 and later; GNU/Linux only)
The command for SVR.JS installation is available in [the SVR.JS home page](https://svrjs.org). First off, switch to _GNU/Linux_ tab, then copy the command below the tab into the terminal. The command looks something like this: `curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240509.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh`. After starting the installer, you will be prompted to select the type of SVR.JS installation. After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, the server is started at _http://localhost_. The command for SVR.JS installation is available in [the SVR.JS home page](https://svrjs.org). First off, switch to _GNU/Linux_ tab, then copy the command below the tab into the terminal. The command looks something like this: `curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240509.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh`. After starting the installer, you will be prompted to select the type of SVR.JS installation. After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, the server is started at _http://localhost_.
@ -22,7 +22,7 @@ SVR.JS installer will also install these commands:
- _svrpasswd_ - SVR.JS user management tool - _svrpasswd_ - SVR.JS user management tool
- _svrjs-updater_ - SVR.JS updater - _svrjs-updater_ - SVR.JS updater
#### Using SVR.JS installer (installer packages made before April 5, 2024; GNU/Linux only) ## Using SVR.JS installer (installer packages made before April 5, 2024; GNU/Linux only)
SVR.JS now has a brand new installer for GNU/Linux. First, [download SVR.JS installer](https://downloads.svrjs.org/installer), then unpack your SVR.JS installer zip archive. After unpacking the installer, download SVR.JS zip archive (not installer), copy it to the installer directory and rename it to "_svrjs.zip_". Then run SVR.JS installer using `sudo bash installer.sh`. After starting the installer, you will be prompted to select the type of OS (type of GNU/Linux distribution). After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to start SVR.JS and get a web server on _http://localhost_. SVR.JS now has a brand new installer for GNU/Linux. First, [download SVR.JS installer](https://downloads.svrjs.org/installer), then unpack your SVR.JS installer zip archive. After unpacking the installer, download SVR.JS zip archive (not installer), copy it to the installer directory and rename it to "_svrjs.zip_". Then run SVR.JS installer using `sudo bash installer.sh`. After starting the installer, you will be prompted to select the type of OS (type of GNU/Linux distribution). After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to start SVR.JS and get a web server on _http://localhost_.
@ -39,7 +39,7 @@ SVR.JS installer will also install these commands:
- _svrjs-logviewer_ - SVR.JS log viewer - _svrjs-logviewer_ - SVR.JS log viewer
- _svrpasswd_ - SVR.JS user management tool - _svrpasswd_ - SVR.JS user management tool
#### Using _create-svrjs-server_ tool ## Using _create-svrjs-server_ tool
To install SVR.JS using _create-svrjs-server_, first install the utility using `npm install -g svrjs`. Then create a directory, which will contain SVR.JS. Change your working directory to a new one, and run one of those commands: To install SVR.JS using _create-svrjs-server_, first install the utility using `npm install -g svrjs`. Then create a directory, which will contain SVR.JS. Change your working directory to a new one, and run one of those commands:
@ -60,11 +60,11 @@ Restart SVR.JS to get server interface.
After running this command again, you'll get a web server on _http://localhost_. After running this command again, you'll get a web server on _http://localhost_.
#### Using Docker ## Using Docker
To install SVR.JS via Docker, first pull the image using `docker pull svrjs/svrjs` command, or `docker pull svrjs/svrjs:lts` command, if you wish to install LTS version of SVR.JS. Then create and start the Docker container using `docker run --name mysvrjs -d -p 80:80 --restart=always svrjs/svrjs` command (replace `mysvrjs` with desired Docker container name). The file structure is the same, as it would be installed via SVR.JS installer. Once the installation is done, the server is started at _http://localhost_. To install SVR.JS via Docker, first pull the image using `docker pull svrjs/svrjs` command, or `docker pull svrjs/svrjs:lts` command, if you wish to install LTS version of SVR.JS. Then create and start the Docker container using `docker run --name mysvrjs -d -p 80:80 --restart=always svrjs/svrjs` command (replace `mysvrjs` with desired Docker container name). The file structure is the same, as it would be installed via SVR.JS installer. Once the installation is done, the server is started at _http://localhost_.
#### Manual installation ## Manual installation
To install SVR.JS manually, first unpack your SVR.JS zip archive you downloaded from SVR.JS download page. Then change your working directory to one containing SVR.JS script stub, and run `node svr.js` for SVR.JS 3.x or `node svr_new.js` for earlier versions or `bun run svr.js` if you're using Bun instead of Node.JS. To install SVR.JS manually, first unpack your SVR.JS zip archive you downloaded from SVR.JS download page. Then change your working directory to one containing SVR.JS script stub, and run `node svr.js` for SVR.JS 3.x or `node svr_new.js` for earlier versions or `bun run svr.js` if you're using Bun instead of Node.JS.
@ -81,7 +81,7 @@ After running this command again, you'll get a web server on _http://localhost_,
![SVR.JS console](/img/svrjs-console.png) ![SVR.JS console](/img/svrjs-console.png)
#### After installation ## After installation
When you visit `localhost`, the page will look like this: When you visit `localhost`, the page will look like this:

View file

@ -2,7 +2,7 @@
title: SVR.JS commands title: SVR.JS commands
--- ---
### SVR.JS commands # SVR.JS commands
SVR.JS comes with a console interface that provides several built-in commands for managing the server and interacting with it. SVR.JS comes with a console interface that provides several built-in commands for managing the server and interacting with it.

View file

@ -2,7 +2,7 @@
title: SVR.JS files title: SVR.JS files
--- ---
### SVR.JS files # SVR.JS files
- _svr.js_ - main SVR.JS script - _svr.js_ - main SVR.JS script
- _config.json_ - SVR.JS configuration file - _config.json_ - SVR.JS configuration file

View file

@ -2,7 +2,7 @@
title: SVR.JS utilities title: SVR.JS utilities
--- ---
### SVR.JS utilities # SVR.JS utilities
SVR.JS 3.0.0 and later comes with several utilities: SVR.JS 3.0.0 and later comes with several utilities:

View file

@ -2,15 +2,15 @@
title: Updating SVR.JS title: Updating SVR.JS
--- ---
### Updating SVR.JS # Updating SVR.JS
#### Using SVR.JS updater (included in SVR.JS installer package; GNU/Linux only) ## Using SVR.JS updater (included in SVR.JS installer package; GNU/Linux only)
If you installed SVR.JS using installer packages in April 5, 2024 and later, you can just run `sudo svrjs-updater` command to update SVR.JS to latest version. Once the update is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to restart SVR.JS. If you installed SVR.JS using installer packages in April 5, 2024 and later, you can just run `sudo svrjs-updater` command to update SVR.JS to latest version. Once the update is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to restart SVR.JS.
For older installer packages, SVR.JS can be updated using SVR.JS updater by changing working directory to one containing SVR.JS updater, and running `sudo bash updater.sh` (**make sure _svrjs.zip_ file contains new version of SVR.JS**). Once the update is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to restart SVR.JS. For older installer packages, SVR.JS can be updated using SVR.JS updater by changing working directory to one containing SVR.JS updater, and running `sudo bash updater.sh` (**make sure _svrjs.zip_ file contains new version of SVR.JS**). Once the update is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to restart SVR.JS.
#### Using _create-svrjs-server_ tool ## Using _create-svrjs-server_ tool
SVR.JS can be updated using _create-svrjs-server_ tool by changing working directory to one containing SVR.JS, and running one of those commands: SVR.JS can be updated using _create-svrjs-server_ tool by changing working directory to one containing SVR.JS, and running one of those commands:
@ -20,6 +20,6 @@ SVR.JS can be updated using _create-svrjs-server_ tool by changing working direc
Then you can run `node svr.js` or `bun run svr.js` to extract new version of SVR.JS and new Node.JS modules. Then you can run `node svr.js` or `bun run svr.js` to extract new version of SVR.JS and new Node.JS modules.
#### Manual updating ## Manual updating
SVR.JS can be updated manually by extracting _svr.js_, _modules.compressed_ and _svr.compressed_ files from archive containing new version of SVR.JS to directory, to which older version of SVR.JS is installed (if you installed SVR.JS using SVR.JS installer, it is _/usr/lib/svrjs_). Then you can run `node svr.js` or `bun run svr.js` to extract new version of SVR.JS and new Node.JS modules. SVR.JS can be updated manually by extracting _svr.js_, _modules.compressed_ and _svr.compressed_ files from archive containing new version of SVR.JS to directory, to which older version of SVR.JS is installed (if you installed SVR.JS using SVR.JS installer, it is _/usr/lib/svrjs_). Then you can run `node svr.js` or `bun run svr.js` to extract new version of SVR.JS and new Node.JS modules.

View file

@ -2,15 +2,15 @@
title: Introduction to SVR.JS mods title: Introduction to SVR.JS mods
--- ---
## Introduction to SVR.JS mods # Introduction to SVR.JS mods
Mods in SVR.JS are custom modules that can extend the server's functionality. Using mods, you can extend SVR.JS functionality to suit your specific requirements and customize the server's behavior to handle different types of requests. Mods in SVR.JS are custom modules that can extend the server's functionality. Using mods, you can extend SVR.JS functionality to suit your specific requirements and customize the server's behavior to handle different types of requests.
### Installing mods ## Installing mods
To install mod to SVR.JS, copy the mod to _mods_ directory inside SVR.JS installation directory. SVR.JS searches this directory for mods, loads and executes them in alphabetical order (by mod file name). If you want have mods to be executed in specific order, add numeric prefix to mod file name, for example "_01-redbrick.cgi.2.3.3.tar.gz_" and "_00-easywaf.integration.1.1.2.tar.gz_". To install mod to SVR.JS, copy the mod to _mods_ directory inside SVR.JS installation directory. SVR.JS searches this directory for mods, loads and executes them in alphabetical order (by mod file name). If you want have mods to be executed in specific order, add numeric prefix to mod file name, for example "_01-redbrick.cgi.2.3.3.tar.gz_" and "_00-easywaf.integration.1.1.2.tar.gz_".
### Mod format ## Mod format
SVR.JS mods are JavaScript files, they work in SVR.JS 4.x and newer SVR.JS mods are JavaScript files, they work in SVR.JS 4.x and newer

View file

@ -2,11 +2,11 @@
title: Mod development title: Mod development
--- ---
### Mod development (_.js_ mods) # Mod development (_.js_ mods)
This section provides a comprehensive guide on developing `.js` mods for SVR.JS. Mods allow you to extend the functionality of SVR.JS by writing custom JavaScript code. This section provides a comprehensive guide on developing `.js` mods for SVR.JS. Mods allow you to extend the functionality of SVR.JS by writing custom JavaScript code.
#### Mod callback ## Mod callback
The main export of the mod is a callback function that handles HTTP requests. This function takes the following parameters: The main export of the mod is a callback function that handles HTTP requests. This function takes the following parameters:
@ -18,7 +18,7 @@ The main export of the mod is a callback function that handles HTTP requests. Th
**You should implement a proxy URL check in the callback, if you're going to use `proxy` callback (or set `proxySafe` in the exports to `true`) and main callback at once, or else your SVR.JS mod may be vulnerable to access control bypass attacks** (SVR.JS doesn't enforce URL rewriting, custom headers and non-standard codes for proxy requests to avoid interference of its access controls with proxy mods). **You should implement a proxy URL check in the callback, if you're going to use `proxy` callback (or set `proxySafe` in the exports to `true`) and main callback at once, or else your SVR.JS mod may be vulnerable to access control bypass attacks** (SVR.JS doesn't enforce URL rewriting, custom headers and non-standard codes for proxy requests to avoid interference of its access controls with proxy mods).
#### Commands ## Commands
Mods can also export commands that can be invoked from the SVR.JS console. The `commands` object maps command names to functions that handle the command logic. Mods can also export commands that can be invoked from the SVR.JS console. The `commands` object maps command names to functions that handle the command logic.
@ -28,7 +28,7 @@ Each command takes the following parameters:
- `log` - the logging function for the command - `log` - the logging function for the command
- `passCommand` - a function to pass control to the next command handler. - `passCommand` - a function to pass control to the next command handler.
#### Proxy handling ## Proxy handling
Mods can handle proxy requests by exporting a `proxy` function. This function takes the following parameters: Mods can handle proxy requests by exporting a `proxy` function. This function takes the following parameters:
@ -43,7 +43,7 @@ Required in order for the main callback to be invoked for request URLs beginning
You can also set `proxySafe` in the exports to `true`, in order to have the same effect described above. You can also set `proxySafe` in the exports to `true`, in order to have the same effect described above.
#### IPC listener ## IPC listener
Mods can communicate with the main process using IPC (Inter-Process Communication). The `process.messageEventListeners` array allows you to add listeners for messages received by the main process. Mods can communicate with the main process using IPC (Inter-Process Communication). The `process.messageEventListeners` array allows you to add listeners for messages received by the main process.
@ -78,13 +78,13 @@ The reserved control messages, used internally by SVR.JS begin with:
- `\x14PINGPING` - `\x14PINGPING`
- `\x14SAVECONF` - `\x14SAVECONF`
#### Paths ## Paths
`process.dirname` refers to the SVR.JS installation directory. `process.dirname` refers to the SVR.JS installation directory.
Current working directory (`process.cwd()`) is SVR.JS web root. Current working directory (`process.cwd()`) is SVR.JS web root.
#### Get started ## Get started
To get started with the development of the mod, clone the Git repository for the SVR.JS mod starter: To get started with the development of the mod, clone the Git repository for the SVR.JS mod starter:
@ -94,7 +94,7 @@ git clone https://git.svrjs.org/svrjs/svrjs-mod-starter.git
Further instructions can be found in the `README` file in the SVR.JS mod starter repository. Further instructions can be found in the `README` file in the SVR.JS mod starter repository.
#### Example mod ## Example mod
Below is an example of `index.js` code for a simple mod from SVR.JS mod starter that handles a `/test.svr` endpoint and a `/ping.svr` endpoint: Below is an example of `index.js` code for a simple mod from SVR.JS mod starter that handles a `/test.svr` endpoint and a `/ping.svr` endpoint:
@ -175,7 +175,7 @@ The `modInfo.json` file would look like this:
} }
``` ```
### Mod development (_.tar.gz_ mods) # Mod development (_.tar.gz_ mods)
Mods in SVR.JS have two methods: Mods in SVR.JS have two methods:

View file

@ -2,7 +2,7 @@
title: Mod files title: Mod files
--- ---
### Mod files (_.tar.gz_ mods) # Mod files (_.tar.gz_ mods)
1. _index.js_ - main script for mod 1. _index.js_ - main script for mod
2. _mod.info_ - information about mod 2. _mod.info_ - information about mod

View file

@ -2,9 +2,9 @@
title: Mod loading order title: Mod loading order
--- ---
### Mod loading order # Mod loading order
#### Startup ## Startup
1. Search for mods 1. Search for mods
2. For each mod (sorted alphabetically by mod file name): 2. For each mod (sorted alphabetically by mod file name):
@ -18,7 +18,7 @@ title: Mod loading order
1. Create mod file from server-side JavaScript 1. Create mod file from server-side JavaScript
2. Initialize "mod", and add "mod" to list 2. Initialize "mod", and add "mod" to list
#### Execution (on each server request) ## Execution (on each server request)
1. Initialize SVR.JS variables 1. Initialize SVR.JS variables
2. Invoke mods and server-side JavaScript (mods sorted alphabetically by mod file name) 2. Invoke mods and server-side JavaScript (mods sorted alphabetically by mod file name)

View file

@ -1,13 +1,13 @@
## First use # First use
### System requirements ## System requirements
#### Minimum ### Minimum
- Node.JS 8.4.0 or newer (SVR.JS 3.4.x and earlier), Node.JS 10.0.0 or newer (SVR.JS 3.5.x and later) / Latest version of Bun (experimental). - Node.JS 8.4.0 or newer (SVR.JS 3.4.x and earlier), Node.JS 10.0.0 or newer (SVR.JS 3.5.x and later) / Latest version of Bun (experimental).
- OS supported by Node.JS/Bun. - OS supported by Node.JS/Bun.
#### Recommended ### Recommended
- Latest Node.JS LTS version. - Latest Node.JS LTS version.
- 2-core CPU or better. - 2-core CPU or better.

View file

@ -2,11 +2,11 @@
title: Migration to SVR.JS title: Migration to SVR.JS
--- ---
### Migration to SVR.JS # Migration to SVR.JS
If you have previously built your web application using the Node.JS http library, Express framework, or Koa framework, you can easily migrate that code to SVR.JS server-side JavaScript. If you have previously built your web application using the Node.JS http library, Express framework, or Koa framework, you can easily migrate that code to SVR.JS server-side JavaScript.
#### From Node.JS http library ## From Node.JS http library
For applications built with the Node.JS http library, you can simply copy the contents of the request event listener to the SVR.JS server-side JavaScript. However, make sure to consider the _disableEndElseCallbackExecute_ option to ensure proper execution flow. For applications built with the Node.JS http library, you can simply copy the contents of the request event listener to the SVR.JS server-side JavaScript. However, make sure to consider the _disableEndElseCallbackExecute_ option to ensure proper execution flow.
@ -25,7 +25,7 @@ if (req.url == "/" && req.method == "GET") {
elseCallback(); // Optionally, invoke main SVR.JS callback. elseCallback(); // Optionally, invoke main SVR.JS callback.
``` ```
#### From Express Framework ## From Express Framework
If your application is built using the Express framework, you can easily migrate it to SVR.JS. You can mix Express methods with SVR.JS methods for more flexibility. If your application is built using the Express framework, you can easily migrate it to SVR.JS. You can mix Express methods with SVR.JS methods for more flexibility.
@ -47,7 +47,7 @@ app.use(elseCallback); // Optionally, if you want the main SVR.JS callback.
app(req, res); // Invoke Express handler app(req, res); // Invoke Express handler
``` ```
#### From Koa Framework ## From Koa Framework
Migrating from the Koa framework to SVR.JS is also straightforward. Here's an example of how you can do it: Migrating from the Koa framework to SVR.JS is also straightforward. Here's an example of how you can do it:

View file

@ -2,11 +2,11 @@
title: Server-side JavaScript title: Server-side JavaScript
--- ---
## Server-side JavaScript # Server-side JavaScript
Another way to expand SVR.JS functionality is through server-side JavaScript located in _serverSideScript.js_ file inside SVR.JS web root (or locaten in SVR.JS installation directory if you're running SVR.JS 3.9.0 or newer, and you have set _useWebRootServerSideScript_ property to _false_). Server-side JavaScript allows you to create various web applications using JavaScript, Node.JS and SVR.JS API. Another way to expand SVR.JS functionality is through server-side JavaScript located in _serverSideScript.js_ file inside SVR.JS web root (or locaten in SVR.JS installation directory if you're running SVR.JS 3.9.0 or newer, and you have set _useWebRootServerSideScript_ property to _false_). Server-side JavaScript allows you to create various web applications using JavaScript, Node.JS and SVR.JS API.
### Predefined objects ## Predefined objects
When working with server-side JavaScript in SVR.JS, you have access to several predefined objects that can greatly enhance your scripting capabilities. These objects are available for use without requiring any additional imports or installations. When working with server-side JavaScript in SVR.JS, you have access to several predefined objects that can greatly enhance your scripting capabilities. These objects are available for use without requiring any additional imports or installations.
@ -26,7 +26,7 @@ Additionally, there is an option to control the automatic execution of the _else
By leveraging these predefined objects, you can streamline your server-side JavaScript code and build powerful applications using SVR.JS. By leveraging these predefined objects, you can streamline your server-side JavaScript code and build powerful applications using SVR.JS.
### Predefined methods ## Predefined methods
_See methods in SVR.JS API in non-proxy section_ _See methods in SVR.JS API in non-proxy section_
@ -37,7 +37,7 @@ SVR.JS 3.8.0 and newer have additionally two methods:
- `checkHref(destHref)` - checks if request path name matches the _destHref_. - `checkHref(destHref)` - checks if request path name matches the _destHref_.
- `checkHostname(hostname)` - checks if host name defined in the request matches the _hostname_ parameter. - `checkHostname(hostname)` - checks if host name defined in the request matches the _hostname_ parameter.
### SSJS development ## SSJS development
`__dirname` and _._ in `require()` function both refer to _temp_ directory in SVR.JS. `__dirname` and _._ in `require()` function both refer to _temp_ directory in SVR.JS.