This file contains hidden or 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
// pages/api/auth/[...nextauth].ts | |
import NextAuth from 'next-auth'; | |
import TwitterProvider from 'next-auth/providers/twitter'; | |
import type { OAuthConfig, OAuthUserConfig, Provider } from 'next-auth/providers'; | |
/** | |
* Supported Provider Type | |
* |
This file contains hidden or 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 { createHash } from "node:crypto"; | |
const COLOR_NAMES = ["red", "green", "blue"]; | |
const COLOR_SHADES = [500, 600, 700]; | |
const COLORS: Record< | |
typeof COLOR_NAMES[number], | |
Record<typeof COLOR_SHADES[number], string> | |
> = { |
This file contains hidden or 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 setTimeoutAsync = < | |
TCallback extends Function = () => void | Promise<void> | |
>( | |
cb: TCallback, | |
delay: number | |
) => | |
new Promise((resolve) => | |
setTimeout(() => { | |
resolve(cb()); | |
}, delay) |
This file contains hidden or 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 { Toaster as RHToaster } from 'react-hot-toast'; | |
import { useMedia } from 'react-use'; | |
import { useTheme } from 'next-themes'; | |
import type { WithProps } from '~/types'; | |
enum ThemeType { | |
LIGHT = 'light', | |
DARK = 'dark', | |
SYSTEM = 'system', |
This file contains hidden or 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
// api/database/incidents.ts | |
interface Incident { | |
id: string; | |
url: string; | |
name: string; | |
} | |
interface UnresolvedIncidentsResponse { | |
page: { |
This file contains hidden or 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
/** | |
* Chunkify | |
* | |
* @description Splits up an array into chnks of arrays of a specified size | |
* | |
* @param {Array} array - The input array that will be chunkified | |
* @param {number} [chunkSize] - The size of each chunk (**Default**: 10) | |
*/ | |
export function chunkify<T>(array: Array<T>, chunkSize: number = 10) { | |
let results = new Array<Array<T>>(); |
This file contains hidden or 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
type ByteFormatStr = 'b' | 'gb' | 'kb' | 'mb' | 'pb' | 'tb'; | |
interface ByteOptions { | |
decimalPlaces?: number; | |
fixedDecimals?: boolean; | |
thousandsSeparator?: string; | |
unit?: ByteFormatStr; | |
unitSeparator?: string; | |
} |
This file contains hidden or 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
// https://twitter.com/bidah/status/1563197138854588417 | |
import reduceRight from 'lodash/reduceRight'; | |
import type { ElementType, ReactNode } from 'react'; | |
interface ComposeProvidersProps { | |
components: Array<ElementType>; | |
children: ReactNode; | |
} |
This file contains hidden or 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
function flipEntries <TValue = unknown> (obj: Record<string, TValue>) { | |
return Object.fromEntries(Object.entries(obj).map(([key, value]) => Array.isArray(value) ? [...value.map((v) => [v, key])] : [[value, key]]).flat()) | |
} |