UNPKG

tezx

Version:

TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an

262 lines (177 loc) โ€ข 4.84 kB
# TezX - High-Performance JavaScript Framework **TezX** is a cutting-edge, high-performance, and lightweight JavaScript framework designed for speed, scalability, and flexibility. Built with modern web development needs in mind, TezX enables efficient routing, middleware management, and static file serving with minimal configuration. It is fully compatible with **Node.js, Deno, and Bun**, making it a truly cross-environment framework. --- ## ๐Ÿš€ Key Features - โšก **High Performance** โ€“ Optimized for speed and scalability. - ๐Ÿ”ฅ **Minimal & Intuitive API** โ€“ Simple yet powerful. - ๐Ÿ—‚๏ธ **Built-in Static File Serving** โ€“ No additional setup required. - ๐Ÿ”Œ **Robust Middleware Support** โ€“ Easily extend functionality. - ๐Ÿงญ **Dynamic & Flexible Routing** โ€“ Define routes with ease. - ๐Ÿ” **Security First** โ€“ Designed with security best practices. - ๐Ÿ“ก **Efficient HTTP Handling** โ€“ Built for high concurrency. - ๐ŸŒ **Cross-Environment Support** โ€“ Node.js, Deno, and Bun ready. --- ## ๐Ÿ“ฆ Installation ### Node.js ```bash npm install tezx ``` ```bash yarn add tezx ```` ### Bun ```bash bun add tezx ``` <!-- ### Deno ```ts import { TezX } from "https://deno.land/x/tezx/mod.ts"; ``` --> --- ## โšก Quick Start ```ts import { TezX } from "tezx"; import { logger } from "tezx/middleware"; import { nodeAdapter } from "tezx/adapter"; const app = new TezX(); app.use(logger()); app.static("/", "./static"); app.get("/", (ctx) => { return ctx.html(` <h1>Welcome to TezX</h1> <p>A modern, high-performance cross-environment framework.</p> `); }); nodeAdapter(app).listen(3001, (message) => { console.log(message); }); ``` --- ## โ–ถ Running the Server ### Node.js ```bash node server.js ``` For development: ```bash npm install -g nodemon nodemon server.js ``` ### Deno ```bash deno run --allow-net server.ts ``` ### Bun ```bash bun run server.js ``` --- ## ๐Ÿ›  Middleware Support ```ts app.use((ctx, next) => { console.log(`Incoming request: ${ctx.req.url}`); return next(); }); ``` --- ## ๐Ÿ“‚ Static File Serving ```ts app.static("/public", "./public"); ``` Files are accessible via `/public/filename.ext`. --- ## ๐Ÿ”€ Routing ```ts app.get("/about", (ctx) => ctx.html("<h1>About Us</h1>")); app.post("/submit", (ctx) => ctx.json({ message: "Form submitted successfully" })); ``` --- ## โš ๏ธ Error Handling ```ts app.onError((err, ctx) => { return ctx.status(500).json({ error: "Internal Server Error" }); }); ``` --- ## ๐Ÿงช Development Setup ### Clone and Install ```bash git clone https://github.com/tezxjs/tezx-app-example cd tezx-app-example npm install tezx@latest ``` ### Run Dev Server ```bash npm run dev ``` > Access at: [http://localhost:3000](http://localhost:3000) --- ## โš™๏ธ Platform-Specific Scripts ### Node.js (Add to `package.json`) ```json "scripts": { "clean": "rm -rf dist", "build:cjs": "tsc --module CommonJS --outDir dist/cjs --removeComments", "build:esm": "tsc --module ESNext --outDir dist/mjs --removeComments", "build:dts": "tsc --module ESNext --outDir dist/types --declaration --emitDeclarationOnly", "build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:dts", "start": "node dist/index.js", "nodemon": "nodemon src/index.ts", "dev": "tsx watch src/index.ts" } ``` ### Bun ```json "scripts": { "dev": "bun run --hot --watch src/index.ts" } ``` `src/index.ts`: ```ts import { bunAdapter } from "tezx/bun"; bunAdapter(app).listen(3000, (message) => { console.log(message); }); ``` ### Deno ```json "scripts": { "dev": "deno run --watch --allow-net --allow-read --allow-env --unstable-sloppy-imports src/index.ts" } ``` `src/index.ts`: ```ts import { denoAdapter } from "tezx/deno"; denoAdapter(app).listen(3000, (message) => { console.log(message); }); ``` --- ## ๐Ÿ— Build & Deployment ### Compile TypeScript to JavaScript Using `tsc`: ```bash npm run build ``` --- ## ๐Ÿค Contributing We welcome contributions! Feel free to: - Fork the repository - Submit a pull request - Open an issue for bugs or suggestions GitHub: [https://github.com/tezxjs](https://github.com/tezxjs) --- ## ๐Ÿ’– Sponsor TezX TezX is an open-source project built with love and passion. If you find it helpful, consider supporting its development: - ๐ŸŒŸ [Star on GitHub](https://github.com/tezxjs/TezX) <!-- - โ˜• [Buy Me a Coffee](https://www.buymeacoffee.com/srakib17) --> - ๐Ÿ’ธ Become a sponsor on [GitHub Sponsors](https://github.com/sponsors/srakib17) Your support helps us maintain and improve TezX for developers around the world. Thank you! ## Our Sponsor [![papernxt](https://papernxt.com/favicon.ico)](https://papernxt.com) --- ## ๐Ÿ“œ License TezX is open-source software licensed under the [MIT License](./LICENSE). ---