Files
splitt-the-bill/shared/utils/slug.ts
T
anbraten cbe1b42f6e
tinyedge/deploy Deployed by TinyEdge
🐛 add env to useDb and apply prettier
2026-08-07 13:28:26 +02:00

76 lines
1.0 KiB
TypeScript

import { customAlphabet } from 'nanoid';
const ADJECTIVES = [
'drunken',
'sleepy',
'grumpy',
'jolly',
'quiet',
'brave',
'clever',
'eager',
'fuzzy',
'gentle',
'happy',
'icy',
'jumpy',
'kind',
'lively',
'mighty',
'noisy',
'orange',
'proud',
'quick',
'rusty',
'silly',
'tidy',
'upbeat',
'vivid',
'witty',
'zesty',
'bold',
'calm',
'dizzy',
];
const NOUNS = [
'wizard',
'tiger',
'otter',
'falcon',
'penguin',
'dragon',
'panda',
'raven',
'walrus',
'yeti',
'badger',
'comet',
'ember',
'fox',
'goose',
'heron',
'igloo',
'jackal',
'koala',
'lemur',
'mango',
'newt',
'oasis',
'puffin',
'quokka',
'robin',
'sloth',
'toucan',
'unicorn',
'viper',
];
const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 6);
export function generateSlug(): string {
const adjective = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)];
const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)];
return `${adjective}-${noun}-${nanoid()}`;
}