View pwd-generator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will receive a word or phrase as a parameter and return the same string but with all the letter "E"s replaced by the number 3 | |
function generateCoolPwd (str) { | |
console.log(str.replaceAll('e', 3).replaceAll('E', 3)) | |
} |
View list-heavy-deps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const listHeavyPackages = packages => packages.split(`\n`).forEach(packageRow => { | |
if (packageRow === ``) return | |
const [s, p] = packageRow.split(`\t`) | |
const size = s.trim() | |
const package = p.trim() | |
if (size.includes('M')) console.log(`${package} might be a heavy package: ${size}`) | |
}) |
View middlewares.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import middy from '@middy/core' | |
import { Logger } from '@aws-lambda-powertools/logger' | |
import { debug } from './core' | |
const logger = new Logger({ | |
logLevel: 'INFO', | |
serviceName: process.env.PROJECT_NAME | |
}) | |
const base = (handler: any) => middy(handler) |
View ssm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm' | |
const secretParameterNameBuilder = (name: string): string => `/env/${process.env.PROJECT_NAME}/${process.env.STAGE}/${name}` | |
export const getParameter = async (name: string): Promise<string> => { | |
const client = new SSMClient({}) | |
const param = secretParameterNameBuilder(name) | |
const { Parameter: { Value } } = await client.send(new GetParameterCommand({ |
View flag-emoji-by-country-code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getFlagEmoji = countryCode => { | |
const codePoints = countryCode | |
.toUpperCase() | |
.split('') | |
.map(char => 127397 + char.charCodeAt()); | |
return String.fromCodePoint(...codePoints); | |
} |