A boilerplate or a sample built in NodeJS without using any NPM packages covering all (or most) of the Node's API modules
NodeJS (LTS) ie. >= 8.11.3
# Clone this repo using your terminal
git clone https://github.com/faizahmedfarooqui/nodejs.git;
# Go inside the repo
cd nodejs;
# Make a data directory into the root of the project
mkdir .data && cd .data;
# Create 3 more directories into the .data directory
mkdir users checks tokens;
# Go back to project's root
cd ..;
# Make a logs directory into the root of the project
mkdir .logs;
# Goto the https directory
cd https;
# Now run the command given in the file keyGeneration.txt
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
- A server to listen to HTTP/HTTPS requests (View Code)
- Deflate / GZIP Compression for HTTP/HTTPS created servers (View Code)
- RESTful API to CRUD and many more for users, tokens & checks (View Code)
- Router for request methods like GET, POST, PUT & DELETE (View Code)
- Handlers(ie. controllers) to handle requests & their methods (View Code)
- Model Base class (View Code)
- A Worker to execute things in background (View Code)
- A logging logic that logs everything into a *.log file (View Code)
- A gzip compression logic which compresses older log file (View Code)
- Local debug environment for the developments in each files (View Code)
- A Web App with template logic & data interpolation (View Code)
- Logic to serve static assets to the web-app (View Code)
- Web routes handler for serving pages & static assets (View Code)
- The CLI tool that runs using node's readline, events libraries & many more (View Code)
- CLI Events handlers (View Code)
- CLI Events responders (View Code)
---------------------------------------------------------------------------------------------------------------------------------------------------------
CLI Manual
---------------------------------------------------------------------------------------------------------------------------------------------------------
exit Kill the CLI (and the rest of the application)
man Show this help page
help Alias of the "man" command
stats Get statistics on the underlying operating system and resource utilization
List users Show a list of all the registered (undeleted) users in the system
More user info --{userId} Show details of a specified user
List checks --up --down Show a list of all the active checks in the system, including their state. The "--up" and "--down flags are both optional."
More check info --{checkId} Show details of a specified check
List logs Show a list of all the log files available to be read (compressed only)
More log info --{fileName} Show details of a specified log file
- Server request are handled using try-catch block & now rather than app crash send 500 error response (View Code)
- For detailed information please use official NodeJS Documentation
- To run this app in debugger mode use command
node inspect index-debug.js
- Added PerformanceObserver Node Class to observe all the entries & log them out to the CLI (View Code)
- Added Performance Mark & Measure methods to measure all the marked performance steps (View Code)
- To see how it works, run command
NODE_DEBUG=performance node index.js
in your terminal
- Added a new file with clusters, here forks are created by the count of the cpus available (View Code)
- To see how it works, run command
node index-cluster.js
in your terminal
- Using
ls
commands into the.logs
folder from CLI commandslist logs
(View Code)
- Use of Async Hooks module (View Code)
- Use of HTTP/2 module in Client & Server Logic (View Code)
- Use of NET module in Client & Server Logic (View Code)
- Use of REPL module (View Code)
- Use of TLS/SSL module in Client & Server Logic (View Code)
- Use of UDP module in Client & Server Logic (View Code)
- Use of VM module (View Code)
Please read the CONTRIBUTING.md
Please read the file CODE_OF_CONDUCT.md