Node.js File System Implementation

Node.js has predefined module for files through which you can do all the file operations like read file, open file, write file. We will discuss the step by step process to read the file and the file management system in node.js.

  • Node File System is implemented using fs module.
  • var fs=require(“fs”)
  • For calling any method we use asynchronous call as it does not block anything as compared to synchronous methods in nodejs.
  • Asynchronous method takes two parameters
  • First parameter is error
  • Second parameter is completion function callback

Below is the example code showing how you can read file in node.js using the fs module

Node.js Read File

  1. var fs = require(“fs”);
  2. fs.readFile(‘test.txt’, function (err, data)
  3. {
  4. if (err)
  5. {
  6. return console.error(err);
  7. }

console.log(“Result: ” + data.toString()); });

NODE.JS Open File:

  1. var fs = require(“fs”);
  2. fs.open(‘input.txt’, ‘r+’, function(err, fd)
  3. { if (err)
  4. {
  5. return console.error(err);
  6.  }
  7. console.log(“File opened successfully!”); });

Node.Js – How to Send Email

In this post we will discuss how you can send email using Node.js. It is important to note that in node.js there is a module for every implementation that you want to do. So if you want to send email using node.js you have to use the nodemailer module. This module is responsible for sending email in node.js. 

  • The Nodemailer module makes it easy to send emails from your computer.
  • The Nodemailer module can be downloaded and installed using npm:

You can also watch the below video to understand the full concept and I have also given some examples through which you can understand this module implementation.

Below is the example code to send emails using nodemailer module of node.js:

First we include the nodemailer module. Once the nodemailer module is included then we create the transport.

Node.js Create Transport :

var nodemailer = require(‘nodemailer’);
var transporter = nodemailer.createTransport({
service: ‘gmail’,
auth: {
user: ‘youremail@gmail.com‘,
pass: ‘yourpassword
}
});

2) Create Email Options like to, from , subject and message :

var mailOptions = {
from: ‘youremail@gmail.com‘,
to: ‘myfriend@yahoo.com‘,
subject: ‘Sending Email using Node.js’,
text: ‘That was easy!’
};

3) Send email using the transport created using nodemailer module of node.js

transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log(‘Email sent: ‘ + info.response);
}
});

 

NODE.JS How to upload files

Node.js File Uploads are done using pre-defined module. In Node.js for every implementation we use the modules. There are many modules for different purposes.

For File Upload we use Formidable module in Node.js. Below are the steps to upload a file using node.js

  • File uploads are done using module called “Formidable”.
  • The Formidable module can be downloaded and installed using NPM:
  • npm install formidable
  • Node.js and formidable module needs to be installed to upload files .

Let us understand this with the help of an example. Below is the example to create a file upload form in node.js

  1. Create index.js file and implement the formidable code inside that
  2. var formidable=require(‘formidable’); // This is the main module that is required
  3. var http= require(‘http’);     // http module is used to create server
  4. http.createServer(function(req,res)
  5. {
  6. res.writeHead(200, {‘Content-Type’: ‘text/html’});
  7. res.write(‘<form action=”fileupload” method=”post” enctype=”multipart/form-data”>’);
  8. res.write(‘<input type=”file” name=”filetoupload”><br>’);
  9. res.write(‘<input type=”submit”>’);
  10. res.write(‘</form>’);
  11. return res.end();
  12. });

 

Now create another file that will upload the file. The above file only creates the form that user will use to upload the file. Below is the fileupload.js code :

var http = require(‘http’);
var formidable = require(‘formidable’);

http.createServer(function (req, res) {
  if (req.url == ‘/fileupload‘) {
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
res.write(‘File uploaded’);
res.end();
});
  } ).listen(8081);

NODE.JS 10 Benefits of Using Node.js

Node.JS 10 Features :

  • NODE 10 is the latest release of Node.js
  • it is packed with new features
  • Node 10 was released April 24, 2018.


The important Features of Node.JS 10 are as follows :

  • Errors have now been standardized
  • It has consistent codes with a repeatable pattern.
  • It will help to resolve the error fast.
  • Previously they only contained a string message with no other identifier associated.
  • If a developer wanted the program to take actions based on a specific message,
  • the only option was to do a string comparison of the error content.

N-API Implementation

  • N-API was experimentally introduced in Node 8
  • N-API is no longer experimental
  • It is independent from the JavaScript runtime
  • and is maintained as part of Node.js itself 
  • Upgrading between Node versions will no longer cause concern for module breakage

Native Node HTTP/2 Features:

  • In node 10 it has great improvements.
  • HTTP/2 improves over the standard HTTP protocol
  • Important Features
  • Multiplexing
  • Single Connection
  • Server Push
  • Prioritization
  • Header Compression

NODE.JS 10 Performance :

  • Node is powered off the V8 JavaScript Engine used in Chromium,
  • and Node.js v10 comes equipped with the latest release.
  • Therefore, we can expect Node 10 to also realize a huge benefit in this area

NODE.JS 10 Has better support for ES Modules

  • Node has been using CommonJS (CJS) which is the require and module.exports syntax.
  • In 2015, a new module system was introduced known as ECMAScript Modules (ESM).
  • Node has been working toward its own implementation of the ESM spec.
  • Integration ESM into Node has not been an entirely smooth path since it does conflict with the current system.

Node.Js Tutorial For Beginners

Node.js is also based on the JavaScript framework, but it is used for developing server-based applications. While going through the entire tutorial, we will look into Node.js in detail and how we can use it to develop server based applications.


Node.Js and its Uses:

  • It is used to build fast and
  • scalable web application.
  • Node.js is a server-side platform
  • built on Google Chrome’s JavaScript Engine .
  • Node.js is an open source, cross-platform runtime environment for developing server-side and networking applications.
  • Node.js applications are written in JavaScript,
  • can be run within the Node.js runtime
  • It uses event driven non blocking I/O model.
  • It is javascript running on the server.
  • The main advantage of Non Blocking I/O is
  • Supports thousands of connections at the same time

Types of Application in NODE.JS

  • Chat , games
  • Backend Programming
  • Blogs & CMS Applications
  • Rest Api
  • (all the real time applications)

What is NPM in Node.Js

  • NPM is Node Package Manager.
  • used to install node modules.
  • All the modules get installed in the specific folder of node.
  • Easy and fast

React Native tutorial

What is React Native?

  • React native is the framework for building native mobile apps using javascript and react library.
  • It is used to create cross platform native apps (IOS/ANDROID)
  • React native basically uses all the concept of react.js in terms of implementing in the code.

 

REACT NATIVE Vs Hybrid apps

 

  • React native apps are different from hybrid apps
  • Hybrid apps run in webview.
  • Ionic , cordova, phonegap framework are used to create hybrid apps.
  • React Native apps are based upon native app concept just like objective c, swift.
  • Are made using building block concept so it is faster and safer as compared to hybrid apps.

Benefits of React Native

  • Apps using react native are faster.
  • Easier to code.
  • It uses javascript and react.js to make cross platform apps(android and ios)
  • Code once.
  • Open source library to make apps.

UI Elements In React Native

  • React native apps have look and feel of the native app as compared to hybrid app which have browser based app like look and feel.
  • Touchable Elements : Just like apps build in objective c.
  • List view
  • Scroll view
  • Alerts
  • Modals
  • Progress Bars
  • Status Bars
  • TabBarIOS (Exclusive for IOS)
  • ToolbarAndroid (Exclusive for Android)
  • Slider
  • TextInput
  • Switch

 

 

Mini Project Topics for CSE IT Students

Minis Project Topics For CSE IT Students

 

Task Monitoring APP (Android App)

This system is designed to alert the user of all the important tasks that are due on a specific day, every week. So now, the user can carry on with his/her life without any worries. The developed project is a tasks reminder app, with AI-powered Chatbot that will make user enjoy productivity. Whether your goal is to make good habits or get rid of bad ones. This application helps you to make sure that the tasks you set actually get done, with the help of its AI assistant.

Voice Assistant For Visually Impaired

This system is used to help the visually impaired to have access to the most important features of the phone enhancing the quality of the system making use of different custom layouts and using speech to text. The System has custom messaging feature with inbox and sent items, call log and dialer, notes and battery level checking and reminder. All actions performed by the user the system speaks out and helps the user to know his current position

 

Android Battery Saver System

System to take the usage from Build-in classes and put a list in front of the user for him to review. The List also consists of the applications taking the battery usage and also determines the battery level. If the Battery level is low and the consumption of apps is more the system will trigger an alarm telling the user to force stop or close the apps.

XAMARIN Tutorial

Xamarin is built on the .NET Framework. It allows one to create apps that easily run across multiple platforms.

Using the Xamarin.Forms UI

Pages, layouts, and views make up the core of the Xamarin.Forms UI . Pages are the primary container, and each screen is populated by a single Page class.

 

 

A page may contain variations of the Layout . The purpose of pages and layouts is to contain and present views, which are controls inherited from class View. Here are the primary pages:

• ContentPage
• MasterDetailPage
• NavigationPage
• TabbedPage
• CarouselPage

Layout
Views are placed and sized by their container class, Layout. Layouts come in a variety of flavors with different features for formatting their views.Here are the main layouts:
• StackLayout
• AbsoluteLayout
• RelativeLayout
• Grid
• ScrollView
• Frame
• ContentView

View

Views are controls, the visible and interactive elements on a page. These range from the basic views like buttons, labels, and text boxes to the more advanced views like lists and navigation. Views contain properties to change the color, font-size and other information of the control.

Basic – fundamental views
• Label
• Image
• Button
• BoxView
• List – make a scrollable, selectable list
• ListView

Xamarin.Forms can be created for

Xamarin.Forms: Cross-platform UI code called by one of the platform-specific projects. This can be accomplished using a shared project, Portable Class Library (PCL), or shared files. The example we’ll be creating in this chapter uses a PCL.

Xamarin.Android: Android-specific code, including Android project startup.

Xamarin.iOS: iOS-specific code, including iOS project startup.

Windows Phone application: Windows Phone–specific code, including Windows Phone project startup.

Core Library: Shared app logic such as business logic and data access layer using a PCL, or a shared project.

 

Upwork

I think the main strength of the upwork is your payment protection.

I have worked on many freelancer website like guru, elance, freelancer and upwork. All the website is good , but when it comes for payment, most of them are escrow based payment.

Now what is escrow payment , in escrow the payment is placed in a safe place , from where neither freelancer nor client can take the money.

Once the job is finished then client approves the payment and then the freelancer website approves and give the payment.

In case of good client it is seamless, but on these website nor every client is good, some are middle person , who have already taken the project and then allocates the project to a freelancer.

once the job is done, they say that they don’t like the work and don’t approve it.

Now what a freelancer can do?

  1. dispute : but again in dispute , the freelancer have to give all the fact about the project, and all the screenshot that he has done. Even if he has done everything , still if the client denies it. The freelancer is not paid.
  2. The other websites hourly work is also not safe. Every one does the work to get paid.
  3. For upwork it is very safe, as the hours are checked based upon work.
  4. If the work done is for the project the freelancer is paid.
  5. Even though the fees for upwork is 20% , in comparison to guru 8%, but still in terms of payment i feel upwork is better.