0% found this document useful (1 vote)
971 views

Node JS - L1: Trend NXT Hands-On Assignments

This document outlines hands-on assignments for learning Node.js. It includes 3 topics with multiple sub-topics and assignments for each: 1) Introduction to Node.js with assignments on modules, callbacks, buffers and streams 2) Node.js Modules with assignments on networking, web programming and events 3) Additional assignments on dates, files and HTTP servers The document provides details on estimated time, learning resources, author and date. It lists 4 minimum assignments to complete.

Uploaded by

Parshuram Reddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
971 views

Node JS - L1: Trend NXT Hands-On Assignments

This document outlines hands-on assignments for learning Node.js. It includes 3 topics with multiple sub-topics and assignments for each: 1) Introduction to Node.js with assignments on modules, callbacks, buffers and streams 2) Node.js Modules with assignments on networking, web programming and events 3) Additional assignments on dates, files and HTTP servers The document provides details on estimated time, learning resources, author and date. It lists 4 minimum assignments to complete.

Uploaded by

Parshuram Reddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Node JS– L1: Trend NXT Hands-on Assignments

Estimated Efforts: 1 PDs

For detailed ToC and other Details: Trend.Nxt URL

Author: [email protected]

Date: 19th May 2018

ToC:

Topic Topic Name Sub Topics Min No of


No Assignments
1 Introduction to Node JS 1. Modules Setting up Node JS Modules 2
2. Call Back Node JS Callback Concepts
3. FS module
4. Buffers Creating Buffers
5. Reading and Writing from Streams
2 Node JS Modules 1. Socket Programming(net module) 2
2. Web Programming(http module)
3. Events module
Total Min No of Assignments 4

Topic 1: Introduction to Node JS:


Assignment 1:
a) Create a Node JS Script file that displays hostname & platform details of current system
on the console.(Hint : Use OS module)
b) Create a Node JS script file that displays “Hello” text in red color and “Welcome to
Node JS” text in rainbow colors on the console. (Hint: Use Colors module)
c) Create a user defined module named “Math” with four functions Addition, Subtraction,
Multiplication, Division and export them. Import Math module form other Node JS Script
file and invoke all the four functions to perform operations on given input.
d) Create a Node JS Script that displays a message “ Welcome to Node JS” through loop,
with delay in between the iterations
i. Using setTimeOut()

Sensitivity: Internal & Restricted


Assignment 2:
a) Create a NodeJS based script file, that provides implementation for ‘pwd’ command from
‘Node’ shell.
b) Create a NodeJS based script file, that reads the name of the directory from the
command line arguments and displays the list of directory contents (using fs module)
c) Create a Node JS script that reads the file name from console and displays the contents of
the file
i. Synchronous mode
ii. Asynchronous mode

d) Create a NodeJS based script file, that reads the names of the 2 files from the user (Use
process module; On stdin “data” event by using call-back accept the input from the user)
and reads the content of first file by using Read Stream API and writes in into second file
by using Write Stream API. If second file is available it should append the content. If not
it should create a new file and add the content to it.

Assignment 3 :
a) Create a user defined date module that can give you the current date and time.
b) Write a Node script file to display current Date & Time by using user defined date
module.
c) Write a Node script file to find out how many seconds are there in a year. How many
seconds are there in a century and writes the result into a file.
d) Create a daysTill custom module. It should be able to give you the number of days
till Christmas and the number of days till mother’s day. number of days till your
Birthday.(Hint : Subtract both the dates to get difference in no.of milliseconds)

Topic 2: Node JS Modules:


Assignment 1:
a) Create Server socket that listens at a port number 3000 and creates sockets for every
client request and sends “Hello Client” message (Hint: Use net module)
b) Send a request to server from browser(http://localhost:3000) & get the response
c) Create a client socket that sends request to the server along with a message “Hello
Server”
d) Test it through ‘telnet’, to see the message echo.

Assignment 2:
a) Create a simple HTTP server that responds to requests with a simple HTML response.
(Hint : using http module)

Sensitivity: Internal & Restricted


b) Create a Node JS Script, using ‘http’ module that downloads the content from a web page
to a file
E.g. to download the google home page
c) Write a Node JS script file to create & emit custom events one, two & three with
messages “First Event” ,”Second Event” & “Third Event” by using Event Emitter class of
Events module
Assignment 3:
a) Create a folder called views (there's nothing special about this folder name, it's
just a common name for one part of a standard MVC pattern). In this folder make a
file called index.html. Add some content to it.

b) Use fs.readFile to get hold of the about.html file. you can use __dirname to get the
current directory. In the fs call back use response.write() to write the file contents
to the response. Finally call response.end to send the index.html file content to the
user.

(Note: call-backs are asynchronous, you don't know how long it will take to start
reading the file, and Node will not wait. This means you will need to call
response.end in the fs call back or the response will be returned before the file has
been read.)

Sensitivity: Internal & Restricted

You might also like