|
Ritik Jain Oodles

Ritik Jain (Backend-Technical Architect)

Experience:6+ yrs

Ritik is an accomplished Backend Developer with extensive experience in Mean. He is proficient in Core Java, Spring-Boot, Hibernate, Node.js, Angular 2+, and various relational databases like MySQL and MongoDB. With his expertise in API implementations, webservices, development testing, and deployments, he has contributed to the successful completion of various client projects. Apart from his professional pursuits, Ritik is an enthusiastic gamer and keeps himself updated with the latest advancements in technology.

Ritik Jain Oodles
Ritik Jain
(Technical Architect)

Ritik is an accomplished Backend Developer with extensive experience in Mean. He is proficient in Core Java, Spring-Boot, Hibernate, Node.js, Angular 2+, and various relational databases like MySQL and MongoDB. With his expertise in API implementations, webservices, development testing, and deployments, he has contributed to the successful completion of various client projects. Apart from his professional pursuits, Ritik is an enthusiastic gamer and keeps himself updated with the latest advancements in technology.

LanguageLanguages

DotENGLISH

Fluent

DotHINDI

Fluent

Skills
Skills

DotJava

100%

DotSpring Boot

100%

DotMySQL

100%

DotNo SQL/Mongo DB

60%

DotFullstack

60%

DotKafka

60%

DotGolang

80%

DotJavascript

80%

DotLinux

80%

DotPinecone

60%

DotNode Js

80%
ExpWork Experience / Trainings / Internship

Feb 2019-Present

Lead Development

Gurgaon


Oodles Technologies

Gurgaon

Feb 2019-Present

EducationEducation

2015-2019

Dot

Teerthanker Mahaveer University

B.Tech -Computer Science and Engineering

Top Blog Posts
Connect SwaggerUI With Nodejs

Swagger With Nodejs

Swagger is an Interface Description Language for describing RESTful APIs expressed using JSON. Swagger is used together with a set of open-source software tools to design, build, document, and use RESTful web services. Swagger includes automated documentation, code generation, and test-case generation.

For connecting swagger with nodejs we have to use two npm packages:-

"swagger-jsdoc": "6.1.0",
"swagger-ui-express": "^4.1.6",

 

Swagger UI Express 

This module allows you to serve auto-generated swagger-ui generated API docs from express, based on a swagger. json file. swagger-jsdoc: Allows you to markup routes with jsdoc comments. It then produces a full swagger yml config dynamically, which you can pass to this module to produce documentation.

 

Swagger Jsdoc

The options object is used by swagger-jsdoc to produce an OpenAPI specification in a variable called swaggerSpec. This specification is equivalent to the swagger. json or swagger. yaml file normally used by Swagger UI for creating docs pages.

To apply swagger, Open app.js and import these packages;-

const swaggerUi = require('swagger-ui-express');
const swaggerJsdoc = require("swagger-jsdoc");

 

Here we need to define the swagger option

var options = {
  definition: {
    openapi: "3.0.0",
    info: {
      title: "Swagger",
      version: "0.1.0",
      description:
        "CRUD Api documentation for node service",
    },
// You can remove this if you don't want bearerAuth
    components: {
      securitySchemes: {
        bearerAuth: {
          type: 'http',
          scheme: 'bearer',
          bearerFormat: 'JWT',
        }
      }
    },
    security: [{
      bearerAuth: []
    }],
    servers: [
      {
        url: "http://localhost:3000",
      },
    ],
  },
  apis: ["./routes/details.js"],
};

 

And pass the option variable into swagger doc

const specs = swaggerJsdoc(options);

 

Now Adding a middleware for the swagger path

app.use(
  "/api-docs",
  swaggerUi.serve,
  swaggerUi.setup(specs,{ explorer: true })
);

 

We have to define some swagger annotation before every API

 /**
   * @swagger
   * /api/data:
   *   get:
   *     description: Returns Some Data
   *     tags: [Task]
   *     parameters:
   *      - in: query
   *        name: userId
   *        type: number
   *        required: true
   *      - in: query
   *        name: date
   *        type: number
   *        required: true
   *     responses:
   *       200:
   *         description: SUCCESS
   */
app.get("/api/data", function(req, res, next) {

});

 

 

Spring Boot with Lombok

Project Lombok

 

Project Lombok is a Java library tool that generates annotations for minimizing the code used for creating functions like getters and setters methods, constructors, hashcode, equals, and toString methods, and so on. The library replaces these codes with easy-to-use annotations.

To use Lombok in our project, we need to download its maven dependency given below:-

<dependency>
   <groupId>org.projectlombok</groupId>
   <artifactId>lombok</artifactId>
   <version>1.18.8</version>
   <scope>provided</scope>
</dependency>

 

There are many annotations available in Lombok like:-

  • @Getter, @Setter
  • @NoArgsConstructor, @AllArgsConstructor
  • @Data
  • @NotNull

 

@Data annotation is equivalent to combination of Lombok’s  @Getter + @Setter + @RequiredArgsConstructor + @ToString + @EqualsAndHashCode.

@Data
public class MessageDto {
  
  private Long id;
  
  private String message;

}

 

If we need to declare getter and setter for any model or DTO then we just use @Getter and @Setter annotation.

import lombok.Getter;
import lombok.Setter;

public class MessageDto {
  
  private Long id;
  
  @Getter @Setter
  private String message;

}

 

We can also use @Getter and @Setter annotations at the class level then Lombok generates getter and setter methods for all the fields.

import lombok.Getter;
import lombok.Setter;

@Gette
@Setter
public class MessageDto {
  
  private Long id;
  
  private String message;

}

 

We can use the @NoArgsConstructor annotation to generate the default constructor that takes no arguments. To generate a constructor with arguments for all the fields, use the  @AllArgsConstructor annotation.

import lombok.*;

@NoArgsConstructor
@AllArgsConstructor
public class MessageDto {
  
  private Long id;
  
  private String message;

}

 

Thanks 

Use Native Sql Query In Grails

In order to use a native query firstly we need to import sql package:-

import groovy.sql.Sql

 

Then we need to inject the dataSource that simply provided the database connection. The DataSource already available in a Grails application, We just need to define the name dataSource as a reference, after this, we can use it in our grails application. 

def dataSource

 

Now we need to create a method that accesses the data source and SQL. Here we can also access the mapped table that is not possible by findBy*

def methodName(User user){
final def query = '''\
select * from tableName as mn INNER JOIN anotherTableName as e ON mn.id = e.table_name_id where mn.subject In (SomeThing) And e.email_string = :email;'''

final Sql sql = new Sql(dataSource)
def mail = sql.rows(query,email: user.email)
return mail
}

 

If dataSource is not available then we simply use the below code to establish the connection with the database:-

 def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbc.JDBCDriver']
 def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)

 

Now you can invoke sql to create a table or to run native query:

sql.execute '''
     create table PROJECT (
         id integer not null,
         name varchar(50),
         url varchar(100),
     )
 '''

 

Thanks 

Asynchronous programming in Nodejs

The Classical Approach - Callbacks

 

Let us explore these simple async operations. Here, the operation is to just start a timer, and at the end of the timer call a function. 

 

function fastFunction (done) {
  setTimeout(function () {
    done()
  }, 100)
}

function slowFunction (done) {
  setTimeout(function () {
    done()
  }, 300)
}

 

Also Read: How to Create Freshdesk Serverless App using Nodejs

 

Although we can execute the higher-order functions either sequentially or in parallel with the basic "pattern" by nesting callbacks, however, the method can result in an untameable callback-hell.

 

function runSequentially (callback) {
  fastFunction((err, data) => {
    if (err) return callback(err)
    console.log(data)   // results of a
  
    slowFunction((err, data) => {
      if (err) return callback(err)
      console.log(data) // results of b
  
      // here you can continue running more tasks
    })
  })
}

 

Also Read: Using a template engine in Nodejs

 

To handle this issue, we need to use the following approaches:-

 

Using Promises

function fastFunction () {
  return new Promise((resolve, reject) => {
    setTimeout(function () {
      console.log('Fast function done')
      resolve()
    }, 100)
  })
}

function slowFunction () {
  return new Promise((resolve, reject) => {
    setTimeout(function () {
      console.log('Slow function done')
      resolve()
    }, 300)
  })
}

function asyncRunner () {
    return Promise.all([slowFunction(), fastFunction()])
}

 

Using async and await 

function scaryClown() {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve('??');
    }, 2000);
  });
}

async function msg() {
  const msg = await scaryClown();
  console.log('Message:', msg);
}

msg();

 

Thanks for reading.

 

Also Read: Using The Microservices and NodeJS

 

Turn To Our SaaS Application Development Services For A Great Return

 

We are a 360-degree software development company that provides complete web and mobile app development solutions for varied project requirements. Our end-to-end SaaS app development services address your mission-critical project requirements through scalable, responsive, and feature-rich software applications that are easy to scale. We carefully analyze your project requirements and formulate effective strategies to build enterprise-grade web and mobile applications for multiple platforms. For more info, contact us at [email protected].

Use desktopCapturer In Electron Applications

First, we need to import desktopCapturer given below:-

import { ipcRenderer, webFrame, remote, screen, desktopCapturer } from 'electron';

desktopCapturer: typeof desktopCapturer;

 

Now we set the screen capture to 1 min by default:- 

let frequencyCount = 1;
       if(this.duration%frequencyCount == 0){
              this.captureScreen.emit('fired');
 }

 

Then call the screenCatpure function:-

  captureScreen(cb){
      const screenSize = this.screen.getPrimaryDisplay().workAreaSize;
      let options = { types: ['screen'], thumbnailSize: screenSize };
      this.desktopCapturer.getSources( options, function(error, sources) {
        if(error) cb({ error: error, imgdata: null });
        for (let source of sources) {
          if(source.name === 'Entire screen' || source.name === 'Screen 1'){
            cb({ error: null, imgdata: source.thumbnail.toDataURL() });
          }
        }
      })
  }

 

Also Read: How to use ioHook in electron application

 

The desktopCapturer module has the following methods:

types String[] - An array of Strings that classifies the kind of desktop sources to be captured from any of the following available kinds, screen & window.

thumbnailSize Size (optional) - It refers to the size of the media source thumbnail. The default is 150 x 150. To save the processing time for capturing the content of each window and screen, set width or height to 0. In this way, you won't have thumbnails.

fetchWindowIcons Boolean (optional) - To fetch window icons, set to true. By default, the value is false. When false, the appIcon property of the sources returns null. Also, the value is false when a source has the type screen.

 

The array of source objects is defined as a Source. Each one of them represents a captured screen or individual window, and possess the following properties:

id String - It refers to the ID of the window or screen being captured in the navigator.webkitGetUserMedia. It appears somewhat in the following format: window:XX or screen:XX, where XX is a randomly generated number.

name String - The specified name of the screen or window being captured. When we have the screen as a source, the name will be Entire Screen or Screen <index>; if it is a window, we will have the window's title as the name.

thumbnail NativeImage - A thumbnail image.

Thanks

 

We are a 360-degree software development company that provides complete web and mobile app development solutions for varied project requirements. Our end-to-end SaaS app development services address your mission-critical project requirements through scalable, responsive, and feature-rich software applications that are easy to scale. We carefully analyze your project requirements and formulate effective strategies to build enterprise-grade web and mobile applications for multiple platforms. For more info, contact us at [email protected]

How to use ioHook in electron application

The content described in the following module can handle keyboard and mouse events via native hooks inside and outside your JavaScript/TypeScript application.

It is fully compatible with Electron. First, you have to install the dependencies of iohook given below-:

 

"dependencies": {

"iohook": "^0.6.5",

}

 

And also add iohook properties in package.json file:-

 "iohook": {
    "targets": [
      "node-64",
      "electron-69"
    ],
    "platforms": [
      "win32",
      "darwin",
      "linux"
    ],
    "arches": [
      "x64",
      "ia32"
    ]
  }

 

Now import iohook in your main.ts file:-

'use strict';

const ioHook = require('iohook');

ioHook.on('mouseup', event => {
  mouseMoveCount = mouseMoveCount+1;
  console.log("====Mouse===>>>",mouseMoveCount);
});
ioHook.on('keydown', event => {
  keyboardClickCount = keyboardClickCount+1;
  console.log("====keyboard===>>>",keyboardClickCount);
});

 

Note:- You can also add iohook in the index.html. It will work fine as well. 

If you want to handle iohook dynamically then you have to add two functions which are used to start and stop the iohook functionality. Functions are given below:-

ipcMain.on('onMouseAndKeyBoardCount', (event, data) => {
 ioHook.start();
 event.returnValue = { status: "SUCCESS", message: "Mouse and keyboard count On", data: { } };
})

ipcMain.on('offMouseAndKeyBoardCount', (event, data) => {
  ioHook.stop();
  event.returnValue = { status: "SUCCESS", message: "Mouse and keyboard count Off", data: { } };
 })

 

In this, we are using electron function ipcMain and ipcRenderer.

offMouseAndKeyBoardCount(taskData){
  return this._electronService.ipcRenderer.sendSync('offMouseAndKeyBoardCount',taskData);
}

saveMouseAndKeyBoardCount(taskData){
  return this._electronService.ipcRenderer.sendSync('saveMouseAndKeyBoardCount',taskData);
}

 

Thanks.

 

We are a 360-degree software development company that provides complete web and mobile app development solutions for varied project requirements. Our end-to-end SaaS app development services address your mission-critical project requirements through scalable, responsive, and feature-rich software applications that are easy to scale. We carefully analyze your project requirements and formulate effective strategies to build enterprise-grade web and mobile applications for multiple platforms. For more info, contact us at [email protected]

Connect Angular with Spring Boot

Connect angular2+ with spring boot and  request or response exchange process

For this, you must have little knowledge of spring-boot API making. But I will cover all concept of angular2+ and also tell you about how to send a request through @RequestParams and @RequestBody from angular2+.

Setup Angular2+

You're going to need a couple of things before proceeding:

  • Node.js
  • Node Package Manager (NPM)

To check whether or not you have both of these installed, visiting your command line or console and type:

$ node -v
$ npm -v

If nodejs is not installed then go to Nodejs.org and download/install it.

We are going to install angular5 with the help of npm.

$ npm install @angular/cli -g
$ ng -v
$ ng new my-new-project --style=scss --routing
$ cd my-new-project
$ ng serve

Now angular5 is ready to work. Let start with integration part.

Go in app.component.ts

 

import {AppService} from './app.service';
export class AppComponent {
constructor(private appService:AppService) {
}
arrayOfTags: Array<String> = [];
getAllTags(){
this.appService.getAllTags().subscribe((response)=>{
this.arrayOfTags = response.data.tagsList;
},(errorRes) => {
})
}
}
 

Now go in app.service.ts

 
import { Injectable } from '@angular/core';
@Injectable()
export class AppService {
constructor(private httpHttpClient) {
}
getAllTags(): Observable<any> {
return this.http.get<any>('http://localhost:8080/tags');
}
}
 
"http://localhost:8080" port where our spring boot application running and /tags is the API created in sprint-boot.
 
Spring boot /tags API code is given below-:
@GetMapping("/tags")
	public ResponseEntity<Object> getTags(){
		Map<String ,Object> response = blogService.getTags(accessToken);
		return ResponseHandler.generateResponse(HttpStatus.OK, true, "Tag list", response);
	}
Send a request using RequestParams.
 
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
@Injectable()
export class BlogService {
constructor(private http: HttpClient) {
}
getEditBlogDetails(id): Observable<any> {
let params =new HttpParams();
params=params.append("id",id);
return this.http.get<any>('http://localhost:8080/getBlogDetails',{params:params});
}
}
 
 
Send a request using RequestBody.
 
submitBlog(title,body):Observable<any>{
return this.http.post<any>('http://localhost:8080/submitBlog',{title:title,body:body});
}
 
Looking for an app developer for mobile app development using Angular Js platform click this link
 
 
Banner

Don't just hire talent,
But build your dream team

Our experience in providing the best talents in accordance with diverse industry demands sets us apart from the rest. Hire a dedicated team of experts to build & scale your project, achieve delivery excellence, and maximize your returns. Rest assured, we will help you start and launch your project, your way – with full trust and transparency!