Posts

Standard Way To Setup Node JS Project With TypeScript

Image
As you know in programming world  JavaScript  is becoming quite famous programming language so in this blog we will discuss how we can create fresh project of  NodeJS with TypeScript  in standard way. What is Node JS? It s a cross-platform, open-source, and server-side JavaScript runtime environment that executes JavaScript code outside a web browser. What is TypeScript? TypeScript is an open-source language maintained and developed by Microsoft. It's loved and used by a lot of software developers around the world. If you want to Setup with only Node JS Then here is the Link . Requirements Any server should be installed either Apache or Nginx. NodeJS and NPM should be  installed  in the operating system.  First open your terminal and go to your project directory then run following commands ~ npm init (after hitting this command it will ask some basic questions you can answer it as per your needs) { " name " : " kafka-nodejs-real-time-app " , ...

Rate Limiting in Node with Express

Image
Rate Limiting is Most Common Practice to Limit The Incoming Request of API's  Rate Limit in Node.js - Education Funda Let's see how we can achieve it easily in Node with Express framework: You need to install rate limit package via ~$ npm i express-rate-limit . import * as RateLimit from 'express-rate-limit' ; const env = process . env . NODE_ENV || 'dev' ; const rateLimitRequest = Number ( process . env . RATE_LIMIT_TIME ) || 15 ; const rateLimitTime = Number ( process . env . RATE_LIMIT_REQUEST ) || 100 ; export default () => { if ( env === 'production' ) { return new RateLimit ({ windowMs: rateLimitTime * 60 * 1000 , // 15 minutes max: rateLimitRequest , // limit each IP to 30 requests per windowMs delayMs: 0 , handler: 'Rate limt exceeded, please try again later some time.' , }); } return new RateLimit ({ windowMs: 5 * 60 * 1000 , // 5 minutes max: 3000 , // ...

Postman Collection APIs to Swagger Docs

Image
Being an back-end developer we generally works with APIs, for storing the APIs mostly developers are using the Postman, So in this blog will discuss how to covert postman collection APIs to swagger APIs documentation. Express Js Project Convert Postman Collection APIs to Swagger Docs Step 1: You should have proper APIs postman collection for your project. Step 2: Install swagger ui in your node project via ~ npm i swagger-ui-express . Step 3: Put below code in your Routes index file OR app.js wherever you maintained your express routes as per your requirements: Here you also need to create 1 json file for storing the details of your APIs docs just like we create swagger-output.json . import express from "express" ; import swaggerUi from "swagger-ui-express" ; const swaggerDocument = JSON . parse ( await readFile ( new URL ( "../../../../swagger-output.json" , import .meta. url )) ); const router = express . Router (); // adding swagger docs...

AWS CloudWatch Check Logs of Lambdas

Image
While working in Microservices concept, you generally need to check CloudWatch logs in deep to identify the errors and debugging your code. So let's see how we can check logs insight of particular lambda. AWS CloudWatch - Education Funda Recent Logs For recent logs you can directly go into Lambda inside it monitor section. Lambda Logs Monitor Filter Logs Old Logs Insights Go down in Monitor logs and go to Recent Invocations section, on top right sight you can see 3 dots for action: Go in Logs Insight for Lambda Next screen will open like below in which you can run query and after that in graph you can select specific date and time logs very easily. Thanks for reading this blog, I hope it is helpful for you, please share your feedback in comments section guys. <> Happy Coding </> 💻

Connect with Oracle DB in Node JS

Image
Let's see how can we connect with oracle db in node js project or lambda Oracle DB - Education Funda First step is to install oracle db package with below command: ~ npm i  oracledb Let's see the code for connecting with oracle db for lambda handler: const oracledb = require ( "oracledb" ); oracledb . outFormat = oracledb . OUT_FORMAT_OBJECT ; exports . handler = async ( event , context , callback ) => { let connection ; const uatConnObj = { user : "db_user_name" , password : "db_pass" , connectString : "ip:port/db" , poolMax : 1 , poolMin : 0 , poolIncrement : 10 , }; const prodConnObj = { user : "db_user_name" , password : "db_pass" , connectString : "ip:port/db" , poolMax : 1 , poolMin : 0 , poolIncrement : 10 , }; try { await oracledb . createPool ( prodConnObj ); let dbPool = oracledb . getPool (); ...

MongoDB Helpful Queries

Image
While doing the development everyones know that no one can remember all of the queries and commands. So in the blog I am covering most used Mongo DB queries. Mongo DB Queries By Education Funda Mongo DB Queries For Studio 3T and In Your Code Fetch Queries: db . getCollection ( "collectionName" ). find ( { FILTER_COLUMN_NAME : 'VALUE' }, { PROJECTION_COLUMN_NAME_1 : 1 , PROJECTION_COLUMN_NAME_2 : 1 } ) Get Duplicates Records db . getCollection ( "collectionName" ). aggregate ([ { "$group" : { "_id" : "$DUP_COL_NAME" , "count" : { "$sum" : 1 } } }, { "$match" : { "_id" : { "$ne" : null } , "count" : { "$gt" : 1 } } }, { "$project" : { "DUP_COL_NAME" : "$_id" , "_id" : 0 } } ]) Count Query db . getCollection ( "collectionName" ). countDocuments ( { FILTER_COL_1 : ...

How To Create S3 Bucket In AWS And Connect With Node JS

Image
a AWS S3 Bucket - Education Funda Create Policy Add ARN Create User as Allow and Create Role ? Add s3-user-policy as permission Now go into user and create access and secret key