diff --git a/pages/docs/api/svrjs-api-legacy.md b/pages/docs/api/svrjs-api-legacy.md index f42929d..77df4f7 100644 --- a/pages/docs/api/svrjs-api-legacy.md +++ b/pages/docs/api/svrjs-api-legacy.md @@ -2,15 +2,15 @@ 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. -### 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. -#### Incorrect Error Handling: +### Incorrect Error Handling: ```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: -#### Correct Error Handling: +### Correct Error Handling: ```js //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. -### 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: @@ -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). -#### _req_ +### _req_ _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.url_ refers to request URL after all processing (URL rewriting too) -#### _res_ +### _res_ _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. - Custom headers defined in _config.json_ are set by default. -#### _serverconsole.climessage(message)_ +### _serverconsole.climessage(message)_ Parameters: @@ -140,7 +140,7 @@ Parameters: Sends CLI message to server console. -#### _serverconsole.reqmessage(message)_ +### _serverconsole.reqmessage(message)_ Parameters: @@ -148,7 +148,7 @@ Parameters: Sends request message to server console. -#### _serverconsole.resmessage(message)_ +### _serverconsole.resmessage(message)_ Parameters: @@ -156,7 +156,7 @@ Parameters: Sends response message to server console. -#### _serverconsole.errmessage(message)_ +### _serverconsole.errmessage(message)_ Parameters: @@ -164,7 +164,7 @@ Parameters: Sends response error message to server console. -#### _serverconsole.locerrmessage(message)_ +### _serverconsole.locerrmessage(message)_ Parameters: @@ -172,7 +172,7 @@ Parameters: Sends local error message to server console. -#### _serverconsole.locwarnmessage(message)_ +### _serverconsole.locwarnmessage(message)_ Parameters: @@ -180,7 +180,7 @@ Parameters: Sends local warning message to server console. -#### _serverconsole.locmessage(message)_ +### _serverconsole.locmessage(message)_ Parameters: @@ -188,7 +188,7 @@ Parameters: Sends local message to server console. -#### _responseEnd(body)_ +### _responseEnd(body)_ Parameters: @@ -196,57 +196,57 @@ Parameters: 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_. -#### _ext_ +### _ext_ Extension of resource defined in the request. -#### _uobject_ +### _uobject_ 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. -#### _search_ +### _search_ Query string of URL. Alias for _uobject.search_ -#### _defaultpage_ +### _defaultpage_ **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_". -#### _users_ +### _users_ **WARNING! DEPRECATED** Alias for _configJSON.users_ -#### _page404_ +### _page404_ Alias for _configJSON.page404_ -#### _head_ +### _head_ HTML head read from either _.head_ or _head.html_ file. -#### _foot_ +### _foot_ 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. -#### _elseCallback()_ +### _elseCallback()_ Invokes next SVR.JS mod callback, SVR.JS server-side JavaScript callback or main SVR.JS callback. -#### _configJSON_ +### _configJSON_ _Added in SVR.JS 3.0.0_ @@ -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". -#### _callServerError(errorCode[, extName][, stack][, ch])_ +### _callServerError(errorCode[, extName][, stack][, ch])_ _Added in SVR.JS 3.0.0_ @@ -267,7 +267,7 @@ Parameters: Invokes HTTP error code. If it's unavailable, invokes 501 error code. -#### _getCustomHeaders()_ +### _getCustomHeaders()_ _Added in SVR.JS 3.0.0_ @@ -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. -#### _origHref_ +### _origHref_ _Added in SVR.JS 3.0.0_ Original path name before URL rewriting. -#### _redirect(dest[, isTemporary][, keepMethod][, headers])_ +### _redirect(dest[, isTemporary][, keepMethod][, headers])_ _Added in SVR.JS 3.0.0_ @@ -294,7 +294,7 @@ Parameters: Redirects HTTP client to specific destination. -#### _parsePostData([options], callback)_ +### _parsePostData([options], callback)_ _Added in SVR.JS 3.0.0_ @@ -308,7 +308,7 @@ Parameters: A wrapper over _formidable_ library, which is used for parsing request bodies of POST requests. -#### _authUser_ +### _authUser_ _Added in SVR.JS 3.14.2_ @@ -356,7 +356,7 @@ function checkIfThereIsA401Rule() { } ``` -### Proxy API +## Proxy API _Added in SVR.JS 3.4.21, 3.7.0_ @@ -378,37 +378,37 @@ if (!res.writeHead) { } ``` -#### _req_ +### _req_ _Added in SVR.JS 3.4.21, 3.7.0_ _req_ object is the same, as _req_ object in Node.JS -#### _socket_ +### _socket_ _Added in SVR.JS 3.4.21, 3.7.0_ _socket_ object is the same, as _socket_ object in Node.JS -#### _head_ +### _head_ _Added in SVR.JS 3.4.21, 3.7.0_ _head_ object is the same, as _head_ object in Node.JS -#### _configJSON_ +### _configJSON_ _Added in SVR.JS 3.4.21, 3.7.0_ _See configJSON in non-proxy API_ -#### _serverconsole_ +### _serverconsole_ _Added in SVR.JS 3.4.21, 3.7.0_ _See serverconsole in non-proxy API_ -#### _elseCallback()_ +### _elseCallback()_ _Added in SVR.JS 3.4.21, 3.7.0_ diff --git a/pages/docs/api/svrjs-api.md b/pages/docs/api/svrjs-api.md index 9f49eb4..346f96f 100644 --- a/pages/docs/api/svrjs-api.md +++ b/pages/docs/api/svrjs-api.md @@ -2,15 +2,15 @@ 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. -### 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. -#### Incorrect Error Handling: +### Incorrect Error Handling: ```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: -#### Correct Error Handling: +### Correct Error Handling: ```js //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. -### Main callback API (`module.exports`) +## Main callback API (`module.exports`) _Added in SVR.JS 4.0.0_ @@ -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`. -#### _req_ +### _req_ _Added in SVR.JS 4.0.0_ _req_ object is almost same, as _req_ object in Node.JS -#### _req.socket.realRemoteAddress_ +### _req.socket.realRemoteAddress_ _Added in SVR.JS 4.0.0_ @@ -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` -#### _req.socket.realRemotePort_ +### _req.socket.realRemotePort_ _Added in SVR.JS 4.0.0_ @@ -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` -#### _req.socket.originalRemoteAddress_ +### _req.socket.originalRemoteAddress_ _Added in SVR.JS 4.0.0_ 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_ _Added in SVR.JS 4.0.0_ 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_ _Added in SVR.JS 4.0.0_ A property containing request URL after all processing (URL rewriting too). -#### _req.parsedURL_ +### _req.parsedURL_ _Added in SVR.JS 4.0.0_ A property containing parsed request URL created by a custom URL parser (compatible with legacy URL parser: `url.parse()`) -#### _req.originalParsedURL_ +### _req.originalParsedURL_ _Added in SVR.JS 4.0.0_ 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_ _Added in SVR.JS 4.0.0_ A property that determines if request is a proxy request or not. -#### _req.authUser_ +### _req.authUser_ _Added in SVR.JS 4.0.0_ The name of authenticated HTTP user. If the user wasn't authenticated, the property would be _null_. -#### _res_ +### _res_ _Added in SVR.JS 4.0.0_ _res_ object is almost same, as _res_ object in Node.JS -#### _res.socket.realRemoteAddress_ +### _res.socket.realRemoteAddress_ _Added in SVR.JS 4.0.0_ @@ -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` -#### _res.socket.realRemotePort_ +### _res.socket.realRemotePort_ _Added in SVR.JS 4.0.0_ @@ -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` -#### _res.socket.originalRemoteAddress_ +### _res.socket.originalRemoteAddress_ _Added in SVR.JS 4.0.0_ 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_ _Added in SVR.JS 4.0.0_ 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])_ _Added in SVR.JS 4.0.0_ @@ -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. -#### _res.setHeader(name, value)_ +### _res.setHeader(name, value)_ _Added in SVR.JS 4.0.0_ @@ -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. -#### _res.head_ +### _res.head_ _Added in SVR.JS 4.0.0_ HTML head read from either _.head_ or _head.html_ file. -#### _res.foot_ +### _res.foot_ _Added in SVR.JS 4.0.0_ HTML foot read from either _.foot_ or _foot.html_ file. -#### _res.responseEnd(body)_ +### _res.responseEnd(body)_ _Added in SVR.JS 4.0.0_ @@ -258,7 +258,7 @@ Parameters: 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])_ _Added in SVR.JS 4.0.0_ @@ -271,7 +271,7 @@ Parameters: Invokes HTTP error code. If it's unavailable, invokes 501 error code. -#### _res.redirect(dest[, isTemporary][, keepMethod][, headers])_ +### _res.redirect(dest[, isTemporary][, keepMethod][, headers])_ _Added in SVR.JS 4.0.0_ @@ -284,13 +284,13 @@ Parameters: Redirects HTTP client to specific destination. -#### _logFacilities_ +### _logFacilities_ _Added in SVR.JS 4.0.0_ The log facilities for SVR.JS. -#### _logFacilities.climessage(message)_ +### _logFacilities.climessage(message)_ _Added in SVR.JS 4.0.0_ @@ -300,7 +300,7 @@ Parameters: Sends CLI message to server console. -#### _logFacilities.reqmessage(message)_ +### _logFacilities.reqmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -310,7 +310,7 @@ Parameters: Sends request message to server console. -#### _logFacilities.resmessage(message)_ +### _logFacilities.resmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -320,7 +320,7 @@ Parameters: Sends response message to server console. -#### _logFacilities.errmessage(message)_ +### _logFacilities.errmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -330,7 +330,7 @@ Parameters: Sends response error message to server console. -#### _logFacilities.locerrmessage(message)_ +### _logFacilities.locerrmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -340,7 +340,7 @@ Parameters: Sends local error message to server console. -#### _logFacilities.locwarnmessage(message)_ +### _logFacilities.locwarnmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -350,7 +350,7 @@ Parameters: Sends local warning message to server console. -#### _logFacilities.locmessage(message)_ +### _logFacilities.locmessage(message)_ _Added in SVR.JS 4.0.0_ @@ -360,13 +360,13 @@ Parameters: Sends local message to server console. -#### _config_ +### _config_ _Added in SVR.JS 4.0.0_ This object contains properties from _config.json_ file. -#### _config.getCustomHeaders()_ +### _config.getCustomHeaders()_ _Added in SVR.JS 4.0.0_ @@ -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. -#### _config.generateServerString()_ +### _config.generateServerString()_ _Added in SVR.JS 4.0.0_ @@ -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). -#### _next()_ +### _next()_ _Added in SVR.JS 4.0.0_ 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`) _Added in SVR.JS 4.0.0_ -#### _req_ +### _req_ _Added in SVR.JS 4.0.0_ _req_ object is the same, as _req_ object in Node.JS -#### _socket_ +### _socket_ _Added in SVR.JS 4.0.0_ _socket_ object is the same, as _socket_ object in Node.JS -#### _head_ +### _head_ _Added in SVR.JS 4.0.0_ _head_ object is the same, as _head_ object in Node.JS -#### _logFacilities_ +### _logFacilities_ _Added in SVR.JS 4.0.0_ _See logFacilties in main callback API_ -#### _config_ +### _config_ _Added in SVR.JS 4.0.0_ _See config in main callback API_ -#### _next()_ +### _next()_ _Added in SVR.JS 4.0.0_ _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_ _Added in SVR.JS 4.0.0_ A property containing SVR.JS version. -#### _process.serverConfiguration_ +### _process.serverConfiguration_ _Added in SVR.JS 4.0.0_ A property containing SVR.JS configuration from _config.json_ file. -#### _process.dirname_ +### _process.dirname_ _Added in SVR.JS 4.0.0_ A property containg the SVR.JS installation directory. -#### _process.filename_ +### _process.filename_ _Added in SVR.JS 4.0.0_ A property containg the path to the SVR.JS script. -#### _process.err4xxcounter_ +### _process.err4xxcounter_ _Added in SVR.JS 4.0.0_ A property containg the count of 4xx HTTP errors. -#### _process.err5xxcounter_ +### _process.err5xxcounter_ _Added in SVR.JS 4.0.0_ A property containg the count of 5xx HTTP errors. -#### _process.reqcounter_ +### _process.reqcounter_ _Added in SVR.JS 4.0.0_ A property containg the count of HTTP requests. -#### _process.malformedcounter_ +### _process.malformedcounter_ _Added in SVR.JS 4.0.0_ diff --git a/pages/docs/config/cgi-scgi-jsgi-php.md b/pages/docs/config/cgi-scgi-jsgi-php.md index 1acca6a..17e57bb 100644 --- a/pages/docs/config/cgi-scgi-jsgi-php.md +++ b/pages/docs/config/cgi-scgi-jsgi-php.md @@ -2,11 +2,11 @@ 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) -#### 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: @@ -46,7 +46,7 @@ SVR.JS currently supports PHP-CGI through RedBrick mod. 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. -#### SCGI via OrangeCircle +## SCGI via OrangeCircle 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) -#### 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. @@ -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. -### 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) -#### GreenRhombus notes +## GreenRhombus notes 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-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): diff --git a/pages/docs/config/cli-options.md b/pages/docs/config/cli-options.md index 30f3575..ef14633 100644 --- a/pages/docs/config/cli-options.md +++ b/pages/docs/config/cli-options.md @@ -2,7 +2,7 @@ title: CLI options --- -### CLI options +# CLI options - _-h_, _-?_, _/h_, _/?_ or _--help_ - displays help - _--clean_ - cleans up files created by SVR.JS diff --git a/pages/docs/config/client-secure.md b/pages/docs/config/client-secure.md index 57a370b..ed5d15e 100644 --- a/pages/docs/config/client-secure.md +++ b/pages/docs/config/client-secure.md @@ -2,6 +2,6 @@ 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. diff --git a/pages/docs/config/configuration.md b/pages/docs/config/configuration.md index 6e1b94e..6affcf5 100644 --- a/pages/docs/config/configuration.md +++ b/pages/docs/config/configuration.md @@ -2,11 +2,11 @@ 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: -#### General Configuration +## General Configuration - _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. @@ -24,7 +24,7 @@ The _config.json_ file contains various properties that you can customize to con - _spubport_ (Number) - 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) - 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) - 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 for SVR.JS to display. (In SVR.JS 2.x, it was _domian_) - _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 -#### Error Pages and Logging Configuration +## Error Pages and Logging Configuration - _page404_ (String) - 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) - Option to enable saving logs to a log file. -#### HTTP Configuration +## HTTP Configuration - _enableCompression_ (Boolean, SVR.JS 3.0.0 or newer) - 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). - _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 216-1. Values should be in range from 0 to 232-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) - 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) - 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) - 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) - 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) - 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) - 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: @@ -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**) - 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: diff --git a/pages/docs/config/custom-error.md b/pages/docs/config/custom-error.md index d1f7d19..45406dd 100644 --- a/pages/docs/config/custom-error.md +++ b/pages/docs/config/custom-error.md @@ -2,7 +2,7 @@ title: Custom error pages --- -### Custom error pages +# Custom error pages You can configure SVR.JS to serve custom error pages by adding _.<errorcode>_ (SVR.JS 3.0.0 or newer) or _<errorcode>.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. diff --git a/pages/docs/config/environment.md b/pages/docs/config/environment.md index cb286fa..00febad 100644 --- a/pages/docs/config/environment.md +++ b/pages/docs/config/environment.md @@ -2,13 +2,13 @@ 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_. -#### 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. diff --git a/pages/docs/config/forward-proxy-notes.md b/pages/docs/config/forward-proxy-notes.md index 00d984e..7057773 100644 --- a/pages/docs/config/forward-proxy-notes.md +++ b/pages/docs/config/forward-proxy-notes.md @@ -2,7 +2,7 @@ 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) diff --git a/pages/docs/config/http-auth.md b/pages/docs/config/http-auth.md index 47fdd02..a51ad74 100644 --- a/pages/docs/config/http-auth.md +++ b/pages/docs/config/http-auth.md @@ -2,7 +2,7 @@ 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. diff --git a/pages/docs/config/page-customization.md b/pages/docs/config/page-customization.md index 6ddef61..21b39dc 100644 --- a/pages/docs/config/page-customization.md +++ b/pages/docs/config/page-customization.md @@ -2,7 +2,7 @@ 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. diff --git a/pages/docs/config/reverse-proxy-config.md b/pages/docs/config/reverse-proxy-config.md index ee2ad5b..ec70842 100644 --- a/pages/docs/config/reverse-proxy-config.md +++ b/pages/docs/config/reverse-proxy-config.md @@ -2,7 +2,7 @@ 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) diff --git a/pages/docs/config/user-management.md b/pages/docs/config/user-management.md index 7ad447d..3a9a249 100644 --- a/pages/docs/config/user-management.md +++ b/pages/docs/config/user-management.md @@ -2,7 +2,7 @@ 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] `. Command-line options: diff --git a/pages/docs/config/virtual-hosts.md b/pages/docs/config/virtual-hosts.md index 7e206ac..a93be9a 100644 --- a/pages/docs/config/virtual-hosts.md +++ b/pages/docs/config/virtual-hosts.md @@ -2,7 +2,7 @@ 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. diff --git a/pages/docs/getting-started/features.md b/pages/docs/getting-started/features.md index a9b5dd0..4a08d59 100644 --- a/pages/docs/getting-started/features.md +++ b/pages/docs/getting-started/features.md @@ -2,9 +2,9 @@ title: Features --- -### Features +# Features -#### Static file handling +## Static file handling - Static file serving (even above 2GB) - 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) - Serving from web root different than SVR.JS installation directory -#### Security +## Security - HTTPS support - HTTP/2 support @@ -21,7 +21,7 @@ title: Features - Ability to hide server version - OCSP stapling support (from SVR.JS 3.4.9) -#### Configuration and customization +## Configuration and customization - Configurability via _config.json_ file - Expandability via server-side JavaScript and mods @@ -29,7 +29,7 @@ title: Features - URL rewriting engine - 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) - SNI (Server Name Indication) support @@ -37,18 +37,18 @@ title: Features - Reverse proxy functionality (requires reverse-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 -#### Gateway interfaces +## Gateway interfaces - CGI (Common Gateway Interface) support (requires RedBrick mod) - SCGI (Simple Common Gateway Interface) support (requires OrangeCircle mod) - JSGI (JavaScript Gateway Interface) support (requires YellowSquare mod) - PHP support (PHP-CGI with RedBrick mod or PHP-FPM with GreenRhombus mod) -#### Additional functionality +## Additional functionality - Logging - Ability to display IP addresses, from which originally request was made (from reverse proxies; via X-Forwarded-For) diff --git a/pages/docs/getting-started/installation.md b/pages/docs/getting-started/installation.md index 04eef8f..109e7aa 100644 --- a/pages/docs/getting-started/installation.md +++ b/pages/docs/getting-started/installation.md @@ -2,9 +2,9 @@ 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_. @@ -22,7 +22,7 @@ SVR.JS installer will also install these commands: - _svrpasswd_ - SVR.JS user management tool - _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_. @@ -39,7 +39,7 @@ SVR.JS installer will also install these commands: - _svrjs-logviewer_ - SVR.JS log viewer - _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: @@ -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_. -#### 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_. -#### 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. @@ -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) -#### After installation +## After installation When you visit `localhost`, the page will look like this: diff --git a/pages/docs/getting-started/svrjs-commands.md b/pages/docs/getting-started/svrjs-commands.md index 6b5e34c..22bd9c0 100644 --- a/pages/docs/getting-started/svrjs-commands.md +++ b/pages/docs/getting-started/svrjs-commands.md @@ -2,7 +2,7 @@ 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. diff --git a/pages/docs/getting-started/svrjs-files.md b/pages/docs/getting-started/svrjs-files.md index c046bbd..702003a 100644 --- a/pages/docs/getting-started/svrjs-files.md +++ b/pages/docs/getting-started/svrjs-files.md @@ -2,7 +2,7 @@ title: SVR.JS files --- -### SVR.JS files +# SVR.JS files - _svr.js_ - main SVR.JS script - _config.json_ - SVR.JS configuration file diff --git a/pages/docs/getting-started/svrjs-utilities.md b/pages/docs/getting-started/svrjs-utilities.md index 5311d9b..06ddff8 100644 --- a/pages/docs/getting-started/svrjs-utilities.md +++ b/pages/docs/getting-started/svrjs-utilities.md @@ -2,7 +2,7 @@ title: SVR.JS utilities --- -### SVR.JS utilities +# SVR.JS utilities SVR.JS 3.0.0 and later comes with several utilities: diff --git a/pages/docs/getting-started/updating-svrjs.md b/pages/docs/getting-started/updating-svrjs.md index 18d7be3..d573aad 100644 --- a/pages/docs/getting-started/updating-svrjs.md +++ b/pages/docs/getting-started/updating-svrjs.md @@ -2,15 +2,15 @@ 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. 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: @@ -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. -#### 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. diff --git a/pages/docs/mods/introduction.md b/pages/docs/mods/introduction.md index 81b2530..775a701 100644 --- a/pages/docs/mods/introduction.md +++ b/pages/docs/mods/introduction.md @@ -2,15 +2,15 @@ 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. -### 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_". -### Mod format +## Mod format SVR.JS mods are JavaScript files, they work in SVR.JS 4.x and newer diff --git a/pages/docs/mods/mod-development.md b/pages/docs/mods/mod-development.md index 4f0a89b..3504dfc 100644 --- a/pages/docs/mods/mod-development.md +++ b/pages/docs/mods/mod-development.md @@ -2,11 +2,11 @@ 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. -#### Mod callback +## Mod callback 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). -#### 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. @@ -28,7 +28,7 @@ Each command takes the following parameters: - `log` - the logging function for the command - `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: @@ -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. -#### 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. @@ -78,13 +78,13 @@ The reserved control messages, used internally by SVR.JS begin with: - `\x14PINGPING` - `\x14SAVECONF` -#### Paths +## Paths `process.dirname` refers to the SVR.JS installation directory. 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: @@ -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. -#### 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: @@ -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: diff --git a/pages/docs/mods/mod-files.md b/pages/docs/mods/mod-files.md index 66029fa..460379e 100644 --- a/pages/docs/mods/mod-files.md +++ b/pages/docs/mods/mod-files.md @@ -2,7 +2,7 @@ title: Mod files --- -### Mod files (_.tar.gz_ mods) +# Mod files (_.tar.gz_ mods) 1. _index.js_ - main script for mod 2. _mod.info_ - information about mod diff --git a/pages/docs/mods/mod-loading-order.md b/pages/docs/mods/mod-loading-order.md index 84ade1a..7aafff7 100644 --- a/pages/docs/mods/mod-loading-order.md +++ b/pages/docs/mods/mod-loading-order.md @@ -2,9 +2,9 @@ title: Mod loading order --- -### Mod loading order +# Mod loading order -#### Startup +## Startup 1. Search for mods 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 2. Initialize "mod", and add "mod" to list -#### Execution (on each server request) +## Execution (on each server request) 1. Initialize SVR.JS variables 2. Invoke mods and server-side JavaScript (mods sorted alphabetically by mod file name) diff --git a/pages/docs/requirements.md b/pages/docs/requirements.md index 92f1fe2..2a5a94f 100644 --- a/pages/docs/requirements.md +++ b/pages/docs/requirements.md @@ -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). - OS supported by Node.JS/Bun. -#### Recommended +### Recommended - Latest Node.JS LTS version. - 2-core CPU or better. diff --git a/pages/docs/server-side-javascript/migration.md b/pages/docs/server-side-javascript/migration.md index 1993224..8160c9f 100644 --- a/pages/docs/server-side-javascript/migration.md +++ b/pages/docs/server-side-javascript/migration.md @@ -2,11 +2,11 @@ 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. -#### 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. @@ -25,7 +25,7 @@ if (req.url == "/" && req.method == "GET") { 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. @@ -47,7 +47,7 @@ app.use(elseCallback); // Optionally, if you want the main SVR.JS callback. 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: diff --git a/pages/docs/server-side-javascript/svrjs-ssjs.md b/pages/docs/server-side-javascript/svrjs-ssjs.md index 59ac67d..0da5b32 100644 --- a/pages/docs/server-side-javascript/svrjs-ssjs.md +++ b/pages/docs/server-side-javascript/svrjs-ssjs.md @@ -2,11 +2,11 @@ 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. -### 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. @@ -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. -### Predefined methods +## Predefined methods _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_. - `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.