🏷 |Kyt Kat| is a lightweight, high-performance JavaScript library for serving static files in Node.js applications. It provides a simple yet powerful way to handle static assets with configurable caching policies.
🏷 |کیت کت| یک کتابخانه سبک و پرسرعت جاوااسکریپت برای سرو فایلهای استاتیک در برنامههای Node.js است. این کتابخانه راهی ساده اما قدرتمند برای مدیریت فایلهای استاتیک با سیاستهای کش قابل تنظیم ارائه میدهد.
- 1️⃣ Smart Caching System: Configurable caching policies for different file types / سیستم کش هوشمند با سیاستهای قابل تنظیم برای انواع فایلها
- 2️⃣ Easy Configuration: Simple setup with
kytkat.config.js/ پیکربندی آسان با فایلkytkat.config.js - 3️⃣ CLI Tools: Built-in command line tools for configuration / ابزارهای خط فرمان برای پیکربندی خودکار
- 4️⃣ Wide File Support: Supports images, scripts, fonts, styles and more / پشتیبانی از انواع فایلها شامل تصاویر، اسکریپتها، فونتها و استایلها
- 5️⃣ Performance Optimized: Efficient file handling with minimal overhead / بهینهشده برای عملکرد بالا با حداقل سربار
npm install kytkatCreate a kytkat.config.js file / فایل kytkat.config.js را ایجاد کنید:
import RootCollection from "kytkat/root";
export default new RootCollection(() => ({
configCache: {
images: {
extensions: ["png", "jpg", "webp"],
policy: "public, max-age=31536000, immutable"
},
scripts: {
extensions: ["js", "mjs"],
policy: "public, max-age=3600"
}
},
staticRoot: {
"logo": "./static/images/logo.png",
"main": "./static/js/main.js"
}
}));- You can also use the Kyt Kat CLI and type the following command to automatically generate the config file:
npx kytkat config// app.js---------------------------------Start--------------------------------
// Initialize configuration
import 'kytkat/root';
// server.js---------------------------------App--------------------------------V1
import kitkat from 'kytkat';
import http from 'http';
http.createServer(async (req, res) => {
if (req.url === '/logo.png') {
await kitkat.staticRender("logo", (response) => {
const { data, header } = response;
res.writeHead(200, header);
res.end(data);
});
} else {
res.writeHead(404);
res.end('Not found');
}
}).listen(3000);
// server.js---------------------------------OR---------------------------------V2
import kitkat from 'kytkat';
import http from 'http';
http.createServer(async (req, res) => {
const { method, url } = req;
if (method === 'GET') {
await kitkat.staticRender(url, (response) => {
const { data, header } = response;
res.writeHead(200, header);
res.end(data);
});
} else {
res.writeHead(404);
res.end('Not found');
}
}).listen(3000);# Generate config file automatically
npx kytkat config
# Scan a folder and generate config
npx kytkat generate assets
# Scan with specific file types
npx kytkat generate static -type png jpg css
# Set scan depth
npx kytkat generate src -depth 5configCache: {
images: {
extensions: ["png", "jpg", "webp"],
policy: "public, max-age=31536000, immutable" // 1 year
},
scripts: {
extensions: ["js", "mjs"],
policy: "public, max-age=3600" // 1 hour
},
html: {
extensions: ["html", "htm"],
policy: "no-cache" // No caching
}
}-
Images: png, jpg, jpeg, webp, gif, svg, ico, bmp, tiff
-
Scripts: js, mjs, cjs, json, xml
-
Fonts: woff, woff2, ttf, otf, eot
-
Styles: css, scss, less
-
Documents: html, htm, pdf, doc, xls, ppt
-
Media: mp4, webm, ogg, mp3, wav
-
Minimal memory usage (~5KB per file cache) | حداقل استفاده از حافظه (حدود ۵ کیلوبایت برای هر فایل کش)
-
Non-blocking I/O operations | عملیات ورودی/خروجی غیر مسدودکننده
-
Efficient file handling | مدیریت کارآمد فایلها
-
Smart caching system | سیستم ذخیرهسازی هوشمند
-
Average response time: 5-15ms for static files | میانگین زمان پاسخدهی: 5-15 میلی ثانیه برای فایلهای استاتیک
-
Optimization for frequent files with smart caching | بهینهسازی برای فایلهای پرتکرار با کش هوشمند
-
40% reduction in loading time using advanced Cache-Control | کاهش 40% زمان بارگذاری
Apache License 2.0 © Amir Hussein Muhammadi Fard