/*
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Example 1:
Input: intervals = [[1,3],[8,10],[15,18],[2,6]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlap, merge them into [1,6].
Example 2:
Input: intervals = [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,4] and [4,5] are considered overlapping.
*/
----------------------------------------------------------
Implement Jwt middlewear
const jwt = require('jsonwebtoken')
function authenticate(req, res, next) {
jwt.verify(req.headers, (data) => {
// data.user { }
})
next()
}
function generateToken() {
jwt.sign(userdata, algo, secret_key, (data) => {
// token
})
return token
}
----------------------------------------------------------
//Suppose you need to build a scalable API for processing high-volume data uploads from multiple sources. How would you design the system using Node.js and PostgreSQL?
let temp =fs.createReadStream() //
temp.on('chunk', (chunk) => {
//
})
multer
diskStorage -> middlewear
----------------------------------------------------------
Second highest salary
SELECT MAX(salary) from salary where salary <> (
SELECT MAX(salary) from salary
)
----------------------------------------------------------
What is Closure, write code to demonstrate it
Difference b/w var and let
Is Nodejs single threaded ? How does it handle async operations ?
Eventloop
Promise vs Callbacks
Challenges faced while converting from monolithic to microservices (data inconsistency)
Questions on caching and redis
In microservices if a single service goes down then how to deal with it
----------------------------------------------------------
Round 2
----------------------------------------------------------
Questions on my past work, challenges faced, how did I tackle it, is there any better way to do it
In a distributed system how to handle eventual data inconsistency
Coding:
create a node js app with 2 endpoints,
1 return straightforward response, other performs heavy calculations like fibonacci
How to ensure performance and NodeJS's "non blocking" in such scenario