A complete redesign of RJS, a server package meant to run a MExN web stack. It comes fully equipped to run as either a Web Server or a RESTful API server, giving you the freedom to customize it to your needs.
Current Version: v1.1.4
Last Updated: 2020-10-12
When acquired, the server needs to be setup with prerequesite libraries and configurations. To do this, you can follow this sequence of steps:
- Install
NodeJS
andNPM
(NPM
usually comes withNodeJS
) - Enter the server project's directory (e.g.
rjs2/
) - Run
npm install
(ornpm i
for newer NPM systems) to install NPM Packages and Database Drivers - (Optional) Install your desired database(s) and corresponding drivers
MongoDB and MySQL drivers for NodeJS were included in
npm install
, but feel free to add others as desired - (Optional) Setup/Configure your database(s) as desired
- Basic Setup Routine
- Enter the
rjs2/util/tools/setup/
directory - Run
node setup.js -A
(You may read its documentation for more details)
- Enter the
- (Optional) Configuration for Secure Mode (HTTPS/SSL) operation
- Enter the
rjs2/util/tools/config/
directory - Run
node config.js -A
and follow the prompts (You may read its documentation for more details)
- Enter the
Once setup is complete, the server package will have all resources it needs to run in insecure mode (i.e. without HTTPS/SSL). To enable the server to run in securely, you must obtain CA certificates and any other required SSL/PKI files from a valid Certificate Authority, then complete configuration by performing the optional steps above.
You can start the server by running rjs2/server.js
with NodeJS on the command line. By default, the server is set to run in secure mode using HTTPS/SSL, but will not operate in this mode without proper configuration (see the previous section) and CA certification, which must be obtained separately from a Certificate Authority.
Assuming you are in the rjs2/
directory, below are some short-hand conventions to run the server in different contexts:
- Run in Secure Mode (Default)
node server.js
- Run in Insecure Mode
node server.js -i
- Run with Verbose Logging (i.e. enables console output)
node server.js -v
- Run in a Custom Port
node server.js -p [some port number here...]
Run node server.js -h
for more details.
- Body-Parser v1.19.0+
- Chai v4.2.0+
- EJS v2.7.1+
- ExpressJS v4.17.1+
- Minimist v1.2.0+
- Mocha v6.2.2+
- MongoDB NodeJS Driver v3.3.3+
- MySQL NodeJS Driver v2.17.1+
- NodeJS v8.9.1+
- Sinon v7.5.0+
- ...change the default log file storage directory?
- Open
rjs2/util/settings.js
- Change
this.logdir
to a path you prefer
- Open
- ...change the default port?
- Open
rjs2/util/settings.js
- Change
this.port
to any port number you desire
- Open
- ...log stuff to console?
- You can use the native JavaScript
console.log()
function to log to the console window, but it is recommended to use theLogger.log()
function fromclass Logger
instead, since this class has the added functionality of storing console outputs to the server log files. This class is accessible within your server backend code (or APIs) by:- ...requiring
_lib.js
and accessing it indirectly (e.g.var logger = require('...path to rjs2/util/...' + '_lib.js' ).Logger
), or by - ...directly including it using its full path (e.g.
var logger = require( '...path to rjs/util/...' + 'logger.js' )
).
- ...requiring
- You can read more about
class Logger
by reading the source-code documentation in therjs2/util/logger.js
file
- You can use the native JavaScript
- If I don't run the server with Verbose Logging turned on, will the server still record console output?
-
Yes, as long as you use
class Logger
to output to console using_lib.Logger.log("...")
. This class is accessible within your server backend code (or APIs) by:- ...requiring
_lib.js
and accessing it indirectly (e.g.var logger = require('...path to rjs2/util/...' + '_lib.js' ).Logger
), or by - ...directly including it using its full path (e.g.
var logger = require( '...path to rjs/util/...' + 'logger.js' )
).
- ...requiring
-
By using
_lib.Logger.log()
to log to console, console output may still be stored in log files under the log directory (default isrjs2/log
; to customize, see the previous section).
-
- Currently supports
Linux
andWindows
. Plans forMacOS
support are being developed. - 2020-01-20
- Currently improving various documentation and utilities within the server
- 2020-01-19
- (DONE)
Providing initial setup and support forWindows
deployments
- (DONE)
- 2019-12-10
- (DONE)
Redesigning the static content and API sub-application loading system for rjs2
- (DONE)
- 2019-11-27
- (DONE)
Creating/Documentingutil/tools/config/config.js
, which will allow user prompting for creation of security.js, as well as future configuration files.
- (DONE)