Skip to content

pwmkin/flareio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlareIO

FlareIO is a minimalist yet powerful HTTP backend framework designed with Bun in mind. It enables clean, scalable server applications using modern TypeScript decorators and supports multiple adapters like Express and Fastify.

✨ Built for Bun — but adapter-flexible.


🚀 Features

  • ✅ Simple, decorator-based routing (@Get(), @Post(), etc.)
  • 🔁 Adapter-based architecture — currently supports Express and Fastify
  • 🧠 Lightweight core with clear separation of concerns
  • 🧰 Built-in support for path parameters, body parsing, and structured responses
  • 🔒 Response filters and middleware support
  • 📦 Designed for Bun, but works in Node too
  • 🧪 WIP: response validation (via filters)

📦 Installation

bun install @flare.io/core @flare.io/express

🧪 Example Usage

// src/index.ts

import { FlareApp, ObjectFilter } from "@flare.io/core";
import { ExpressAdapter } from "@flare.io/express";
import { UserRouter } from "./user/user.router";

async function main() {
  const adapter = new ExpressAdapter();
  const app = new FlareApp(adapter);

  app.router(UserRouter); // Register routers

  app.useResponseFilter(new ObjectFilter({ filterArrays: true })); // Filter responses

  app.listen(3000); // Start server
}

main();

📁 Router Example

import {
  Body,
  Delete,
  Get,
  NotFoundException,
  Param,
  Post,
  Put,
  Router,
} from "@flare.io/core";

import { User, UserService } from "./user.service";

@Router("/users")
export class UserRouter {
  private userService = new UserService();

  @Get()
  getAllUsers() {
    return this.userService.getAllUsers();
  }

  @Get(":id")
  getUserById(@Param("id") id: string) {
    const user = this.userService.getUserById(id);
    if (!user) throw new NotFoundException("User not found");
    return user;
  }

  @Post()
  createUser(@Body() userData: Omit<User, "id">) {
    if (!userData.name || !userData.email) {
      return { error: "Name and email are required", status: 400 };
    }
    return this.userService.createUser(userData);
  }

  @Put(":id")
  updateUser(
    @Param("id") id: string,
    @Body() userData: Partial<Omit<User, "id">>
  ) {
    const updatedUser = this.userService.updateUser(id, userData);
    if (!updatedUser) return { error: "User not found", status: 404 };
    return updatedUser;
  }

  @Delete(":id")
  deleteUser(@Param("id") id: string) {
    const success = this.userService.deleteUser(id);
    if (!success) return { error: "User not found", status: 404 };
    return { message: `User ${id} deleted successfully` };
  }
}

🧩 Architecture

FlareIO follows a modular architecture:

@flare.io/core             # Core framework logic (decorators, metadata, filters)
@flare.io/express          # Express adapter
@flare.io/fastify          # Fastify adapter
example                   # Example app

Each adapter implements a shared interface to integrate seamlessly with the core framework.


🧹 Response Filters

FlareIO allows you to register response filters to manipulate the output before sending it to the client.

app.useResponseFilter(new ObjectFilter({ filterArrays: true }));

Built-in filters:

  • ObjectFilter: Removes undefined/null values and filters arrays.

🔍 Roadmap

  • ✅ Adapter system (Express, Fastify)
  • ✅ Routing decorators
  • ✅ Response filters
  • 🧪 Response validation (WIP)
  • 🛡️ Middleware support (planned)
  • 📦 CLI for project scaffolding (planned)
  • 📚 Plugin system (future)

🧑‍💻 Requirements

  • Bun (recommended)
  • TypeScript 5.x
  • Node 18+ (if not using Bun)

📜 License

MIT License — © 2025 Pwmkin


❤️ Contributions

Contributions are welcome! If you have ideas, improvements, or adapter suggestions, feel free to open an issue or PR.


📫 Contact

Have questions or suggestions? Open an issue or reach out via discussions.

About

Minimalist yet powerful HTTP backend framework designed for Bun

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published