Posts

How to Use VIM Editor in CLI

Image
VIM is most popular editor which Developer's generally require to use while Development, Let's see how we can use it: VIM Editor - Education Funda Open a File: ~ vim fileName.ext  To save and exit the Vim editor, you can use the following commands: :wq  This command saves the changes to the file and exits Vim. It is equivalent to “write and quit”. :w : This command saves the changes to the file, but remains in Vim. You can continue editing or use other commands to manipulate the file. :q! : This command exits Vim without saving changes. It is equivalent to “quit bang” and discards any unsaved modifications. Additional Tips To enter command mode, press the Esc key. To switch between insert mode and command mode, use Esc to exit insert mode and return to command mode. Save and exit a file: :wq Save a file without exiting: :w Exit Vim without saving changes: :q! Rename a file and save changes: :w new_filename.txt Save and exit multiple files: :wqa Remember to use these commands

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