Skip to main content

Posts

Showing posts with the label Nodejs

Integrating Kafka with Node.js

Integrating Kafka with Node.js Apache Kafka is a popular open-source distributed event streaming platform that uses publish & subscribe mechanism to stream the records(data). Kafka Terminologies Distributed system: Distributed system is a computing environment where various software components located on different machines (over multiple locations). All components coordinate together to get stuff done as one unit.   Kafka Broker: Brokers are cluster of multiple servers. Message of each topic are split among the various brokers. Brokers handle all requests from clients to write and read events. A Kafka cluster is simply a collection of one or more Kafka brokers. Topics: A topic is a stream of "related" messages. Its unique throughout application. Kafka producers write messages to topics. Producer: Producer publishes data on the topics. A producer sends a message to a broker and the broker receives and stores messages. Consumers: Consumers read data from topics. A consu...

How to implement Real time notification in NodeJs

Here are simple steps to create real time notification using NodeJs, Socket.io and Mysql Socket.IO enables real-time bidirectional event-based communication.It has two parts: a client-side library that runs in the browser, and a server-side library for node.js. Install Socket.IO npm install --save socket.io I hope you have install express and mysql. This are basic few code inside server file. var express = require( 'express' ); var app = express(); app.use( express.static( __dirname + '/public') ); var mysql = require('mysql'); var server = require( 'http' ).Server( app ); var io = require( 'socket.io' )( server ); server.listen( 3000, function(){   console.log( 'listening on *:3000' ); } ); app.get('/', function(req, res) {    res.sendFile(__dirname + '/index.html'); }); The require('socket.io')(http) creates a new socket.io instance attached to the http server. Now make mysql conn...

How to Implement CRUD in Node js With MySQL

How to Implement CRUD in Node.js With MySQL In this post, we are going to create a simple CRUD application in Node.js with MySQL as the database. We are using EJS as the template engine. Before get started with this tutorial: You need to have Node installed. Read my previous post for Node.js installation. Step 1: Create index.js as main file and package.json file package.json { "name": "curdnode", "version": "1.0.0", "description": "Create simple curd example in nodejs", "main": "index.js", "scripts": { "start": "node index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "techsudhir", "license": "ISC" } index.js console.log('Welcome You'); Now open up your command line and run : npm start Output: Welcome You Stop the c...

How to learn NodeJs in 5 steps

NodeJs Entry level Tutorial Node.js is an open-source, cross-platform JavaScript runtime environment for developing a diverse variety of tools and applications. It is a server-side platform built on Google Chrome's JavaScript Engine Follow Basic steps to run your first example Step1: Download Nodejs and install it. Step2: After installation Check NodeJs working or not a) Open Windows Command Prompt b) Execute the Command node -v. It print a version number Example: C:\Users\Sudhir>node -v Output: v6.9.2 c) Execute the Command npm -v . It print NPM’s version number Example: C:\Users\Sudhir>npm -v Output: 3.10.9 Step3: Type npm init and press enter Step4: It will ask for file name, version and description etc Step5: It will create a package.json file { "name": "nodetest", "version": "1.0.0", "description": "Hello test", "main": "index.js", "scripts": { ...