Skip to main content

BurgerAPI v0.5.0 Released

ยท 5 min read
Isfhan Ahmed
Creator of BurgerAPI Framework

We're excited to announce the release of BurgerAPI v0.5.0! This critical update fixes TypeScript support and adds new features to make your API development experience even better.

๐Ÿš€ What's New in v0.5.0โ€‹

Version 0.5.0 (November 1, 2025)โ€‹

  • Fixed: TypeScript types now work perfectly with full IntelliSense
  • New Feature: Auto-injected OPTIONS handlers for CORS preflight
  • Improved: Better middleware response handling
  • Enhanced: Faster builds and cleaner codebase

๐ŸŽฏ Introductionโ€‹

This release focuses on developer experience improvements, particularly around TypeScript support which was a major pain point in previous versions. We've also added automatic CORS preflight handling and improved middleware reliability.

๐Ÿ”ง What Was Fixedโ€‹

TypeScript IntelliSense Now Works Perfectlyโ€‹

The Problem:

In previous versions, when you installed burger-api and tried to use TypeScript types, you got nothing. No autocomplete, no IntelliSense, just errors. This made the developer experience frustrating.

What's Fixed:

Version 0.5.0 completely resolves this issue. Types now work exactly as they should:

import { Burger } from 'burger-api';
import type { BurgerRequest, Middleware, ServerOptions } from 'burger-api';

// โœ… Full autocomplete on options
const burger = new Burger({
title: 'My API', // Hover to see documentation
apiDir: './api', // IntelliSense shows all available options
debug: true,
});

// โœ… Full autocomplete on request object
const middleware: Middleware = (req: BurgerRequest) => {
req.url // โœ… Works!
req.method // โœ… Works!
req.params // โœ… Works!
req.validated // โœ… Works!
return undefined;
};

Benefits for You:

  • Get instant documentation while typing
  • Catch errors before running your code
  • Navigate to type definitions with a click
  • Refactor code safely with IDE support
  • Works in VSCode, Cursor, WebStorm, and all major editors

๐Ÿ’ก What's Newโ€‹

1. Auto-Injected OPTIONS Handler for CORSโ€‹

What It Does:

BurgerAPI now automatically adds OPTIONS handlers to your routes when needed for CORS preflight requests.

Before v0.5.0:

// You had to manually add OPTIONS handler
export async function POST(req: BurgerRequest) {
return Response.json({ message: 'Created' });
}

export async function OPTIONS(req: BurgerRequest) {
return new Response(null, { status: 204 }); // Manual boilerplate
}

After v0.5.0:

// OPTIONS handler is automatically added!
export async function POST(req: BurgerRequest) {
return Response.json({ message: 'Created' });
}

// That's it! No OPTIONS handler needed

How It Works:

  • Detects routes with POST, PUT, DELETE, or PATCH methods
  • Automatically adds a minimal OPTIONS handler returning 204 No Content
  • Only adds it if you haven't defined your own OPTIONS handler
  • Prevents "405 Method Not Allowed" errors during CORS preflight

Benefits:

  • Less boilerplate code
  • No more CORS preflight errors
  • Cleaner route files
  • Works automatically with CORS middleware

2. Improved Middleware Response Handlingโ€‹

What Changed:

Middleware that returns "after" functions now runs more reliably, especially when handling errors or early returns.

Example - CORS Middleware:

const corsMiddleware: Middleware = (req) => {
// Return an "after" function to add headers
return async (response) => {
const headers = new Headers(response.headers);
headers.set('Access-Control-Allow-Origin', '*');
headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');

return new Response(response.body, {
status: response.status,
headers,
});
};
};

Benefits:

  • CORS headers are now applied to ALL responses, including errors
  • More predictable middleware behavior
  • Better error handling in middleware chains
  • After functions run in reverse order (last registered runs first)

๐Ÿšฆ Upgrade to v0.5.0โ€‹

Good news: There are no breaking changes!

Update your project to start using the improved TypeScript support and new features:

bun install burger-api@latest

Your existing code will work without any modifications. You'll just get better TypeScript support and new features automatically.

๐Ÿš€ Quick Start Exampleโ€‹

Try BurgerAPI v0.5.0 right now:

# Install
bun add burger-api

# Create API structure
mkdir -p api/products

Create api/products/route.ts:

import { z } from 'zod';
import type { BurgerRequest } from 'burger-api';

// Define validation schema
export const schema = {
get: {
query: z.object({
search: z.string().optional(),
page: z.string().optional(),
}),
},
post: {
body: z.object({
name: z.string().min(1),
price: z.number().positive(),
}),
},
};

// GET /api/products
export async function GET(req: BurgerRequest) {
return Response.json({
products: [],
query: req.validated.query,
});
}

// POST /api/products (OPTIONS handler auto-added!)
export async function POST(req: BurgerRequest) {
const product = req.validated.body;
return Response.json({ created: product }, { status: 201 });
}

Create index.ts:

import { Burger, setDir } from 'burger-api';

const burger = new Burger({
title: 'My Shop API',
description: 'Products API with auto-validation',
apiDir: setDir(__dirname, 'api'),
version: '1.0.0',
debug: true,
});

burger.serve(4000, () => {
console.log('๐Ÿ” API running at http://localhost:4000');
console.log('๐Ÿ“š Docs at http://localhost:4000/docs');
});

Run it:

bun run index.ts

Visit:

๐Ÿ’ฌ What Developers Are Sayingโ€‹

"Finally! The TypeScript support actually works. This makes BurgerAPI a joy to use."
โ€” Early adopter feedback

"Auto OPTIONS handlers saved me so much boilerplate code. This is how it should be."
โ€” Community feedback

๐Ÿค Get Involvedโ€‹

BurgerAPI is open source and we welcome contributions!


Stay tuned for more updates and happy coding with BurgerAPI! ๐Ÿ”