Skip to content

KiT-Maverik/kotyk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

KOTYK

πŸ‡ΊπŸ‡¦ KOTYK isn't just a cat β€” it's a Ukrainian-grade configuration layer. Strict, type-safe, and always watching your environment variables like a guardian. No undefined, no silent failures, and absolutely no mercy for missing API_KEYs.


πŸš€ Features

  • βœ… Just like real cats, KOTYK reacts instantly β€” that's why it's implemented in seconds.
  • βœ… Built with Zod for runtime type safety
  • βœ… Fails fast at startup if any variables are missing or invalid
  • βœ… Automatically cached via the module system β€” import it anywhere
  • βœ… No more scattered process.env.X β€” just environment.X
  • βœ… Designed for backend apps, CLI tools, SSR, and monorepos

πŸ”  What does KOTYK stand for?

Konfigured Only Typed Yielded Keys

Yes, "Konfigured" with a K. Because this isn't just another kitty β€” KOTYK is a proud πŸ‡ΊπŸ‡¦πŸ˜Ό


πŸ“¦ Installation

yarn add zod dotenv

🧩 KOTYK lives in env.kotyk.ts

import 'dotenv/config';
import { z } from 'zod';

const schema = z.object({
    WHISKER_API_KEY: z.string().min(1, 'WHISKER_API_KEY is required'),
    SCRATCH_RETRY_LIMIT: z.coerce.number().int().min(0, 'Must be non-negative'),
});

export type Environment = z.infer<typeof schema>;

export const environment: Readonly<Environment> = Object.freeze(
    (() => {
        try {
            return schema.parse(process.env);
        } catch (err) {
            console.error('😿 Failed to validate environment variables! KOTYK refuses to start.');
            console.error('πŸ“¦ Did you forget to copy .env.example and set your secrets?\n');
            throw err;
        }
    })()
);

βœ… Usage Example

import { environment } from 'env.kotyk.js';

if (retries > environment.SCRATCH_RETRY_LIMIT) {
  throw new Error('😾 Too many retries! KOTYK scratched the request.');
}

🧾 .env.example

WHISKER_API_KEY=your-whisker-key
SCRATCH_RETRY_LIMIT=3

🧠 Philosophy

  • πŸ”₯ If a variable is missing β€” KOTYK will stop the build
  • 😼 If you try undefined β€” KOTYK will paw your CI
  • 🎯 No more as string, || '', or parseInt() scattered everywhere
  • 🐾 KOTYK is not just a config helper β€” it's your trusted configuration sentinel

🌟 Give the kitty a star!

If this little πŸ‡ΊπŸ‡¦ KOTYK made your config safer or brought a smile to your CI β€” consider giving it a ⭐️!


🌐 License

MIT

But KOTYK reserves the right to stare disapprovingly at anyone who touches process.env directly.