# 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).

---
