Skip to content

Instantly share code, notes, and snippets.

View devAgam's full-sized avatar
👩‍🚀
Working from localhost

Agamjot Singh Jashan devAgam

👩‍🚀
Working from localhost
View GitHub Profile
@devAgam
devAgam / resume.action.js
Created June 12, 2023 07:30
Sample Function to Automate File Uploads through browser extensions
// This function does the following
// 1. fetches the PDF resume from the url provided
// 2. creates a file object with the resume data
// 3. triggers the change event on the file input element
// 4. the file input element gets the file object
// 5. the file object is uploaded to the website
async function handleResumeInput(remoteResumeURL) {
@devAgam
devAgam / api.js
Created October 8, 2022 05:45
URL Ternary decider
import axios from "axios";
const baseUrlMainServer =
process.env.ENV === "PROD"
? "https://api.project28.in"
: process.env.ENV === "QA"
? "https://qa.project28.in"
: (process.env.ENV = "DEV"
? "https://backend-staging.project28.in"
: "http://localhost:5000");
@devAgam
devAgam / gist:815a8bda1968175c4ce6d12fcffa8d1e
Created October 8, 2022 05:45
ENV Url ternary handler
import axios from "axios";
const baseUrlMainServer =
process.env.ENV === "PROD"
? "https://api.project28.in"
: process.env.ENV === "QA"
? "https://qa.project28.in"
: (process.env.ENV = "DEV"
? "https://backend-staging.project28.in"
: "http://localhost:5000");
@devAgam
devAgam / app.js
Created December 31, 2021 08:49
How to delete a key/cached data from redis
app.get("/sileo-depiction-revalidate/:package", async (req, res) => {
const dep_package = req.params.package; // package name
try {
const redisDepKey = `${dep_package}:depiction`; // redis key
return client.del(redisDepKey, async (err, success) => { // check if cached
if (success == 1) { // if success
res.status(200).send({ // send success acknowledgement
httpStatus: 200,
success: true,
@devAgam
devAgam / app.js
Created December 31, 2021 07:30
Sample of Redis cached route in nodejs
app.get("/sileo-depiction/:package", async (req, res) => {
const dep_package = req.params.package; // package name
try {
const redisDepKey = `${dep_package}:depiction`; // redis key
return client.get(redisDepKey, async (err, cachedData) => { // check if cached
if (cachedData) { // if cached
const parsedData = JSON.parse(depiction); // parse cached data
res.status(200).send({ // send cached data
httpStatus: 200,