Home »
Node.js
UPPER-CASE Node.js Module
In this article, we are going to learn about the UPPER-CASE Node.js module, what is it, how to install UPPER-CASE Node.js module, how to use it?
Submitted by Godwill Tetah, on June 06, 2019
Today, let's see a third party module that helps us in working with upper-case letters without necessarily typing them in upper-case in our source code.
You may find it useless! But it's very important.
For example, you may have a form where you require your users to fill in upper-case letters only. You may wish to add a function where any typed in the letter appears in upper-case even though typed in lower-case from the keyboard.
Like said before, Node modules are like libraries which help us perform specific tasks. Node.JS is always considered powerful because it has a very large ecosystem of third-party modules.
The upper-case module is a third-party module built by some experts to help us.
Take Note! You should have Node.js installed in your PC.
With Node.js already up and running, let's get started.
Now, let's get started.
First of all, install the upper-case module by typing npm install upper-case via the command line.
Wait for a while as it downloads.
NB: Internet required!
Take note that only third party modules are installed via command line unlike built in modules which comes along with the node.js environment when downloaded...
Let's look at a basic use of the upper-case module.
We'll create an http server that will output hello world in capital letters but written in small letters in the source code.
Open a text editor and type the following code and save it with the file name app.js:
var http = require('http'); // includes the http module
var uc = require('upper-case'); // include the upper-case module
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(uc("hello world!")); // assign the upper-case module
res.end();
}).listen(8080); // port number
Note: The file should be saved in your default Node.js directory.
Initiate the JavaScript file at the console by typing node app.js
Take Note! : Your command line directory should be same with Node.js module directory.
Finally, open your browser and navigate to http://localhost:8080
Thanks for coding with me. Your comments are most welcome.