Skip to content

Instantly share code, notes, and snippets.

Avatar

Samuel Karani Mbaabu samuelkarani

View GitHub Profile
View apiGrid.controllers-refactor.js
const {
UpdateCounterPartyRisk,
UpdateAssetCounterPartyRisk,
UpdateCounterPartyRiskWithAlerts,
UpdateAssetCounterPartyRiskWithAlerts,
UpdateDDCounterPartyRisk,
UpdateHitStatus,
UpdateBatchStatus,
} = require("@schemas/grid");
const axios = require("axios");
View google drive url apis.js
export const getThumbnail = (id, size = 300) =>
`https://drive.google.com/thumbnail?id=${id}&sz=${size}`;
export const getIcon = (mimeType) =>
`https://drive-thirdparty.googleusercontent.com/256/type/${mimeType}`;
export const getFile = (id) => `https://drive.google.com/uc?id=${id}`;
const downloadFile = (id) =>
View helpers.js
export function validURL(string) {
const pattern = new RegExp(
"^(https?:\\/\\/)?" + // protocol
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
"((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
"(\\#[-a-z\\d_]*)?$",
"i"
); // fragment locator
View JWT-build-your-own.js
//Original Reference: https://guseyn.com/posts/simple-jwt
function payloadWithExpirationTime (payload, minutesFromNow) {
let date = new Date()
date.setMinutes(date.getMinutes() + minutesFromNow)
payload.exp = date.getTime()
return payload
}