Extend Your API

BreezeAPI Plugins

Enhance your API with official plugins that add powerful features with minimal configuration

CORS

Official

Enable Cross-Origin Resource Sharing (CORS) for your API with configurable options.

Installation
bun add @breezeapi/cors
Downloads:323
Version:1.0.4

CRON

Official

Schedule tasks to run at specific intervals using CRON expressions.

Installation
bun add @breezeapi/cron
Downloads:204
Version:1.0.4

Caching

Official

Implement a caching middleware with an redis backend.

Installation
bun add @breezeapi/cache
Downloads:204
Version:1.0.11
Extend BreezeAPI

Create your own plugins

BreezeAPI offers tools to let you create your own plugins easier like a global config object.

  • Hook into request/response lifecycle
  • Add global middleware
  • Extend core functionality
my-plugin.ts

                    import { Config, type apiRequest, type apiResponse, type apiNext } from '@breezeapi/core';
[...]

/**
 * Zod schema for per-route cache configuration.
 * - enabled: Enable or disable caching for this route.
 * - cacheKey: Optional custom cache key. If not provided, the URL will be used.
 * - duration: Cache duration in seconds.
 */
export const cacheConfigSchema = z.object({
    enabled: z.boolean().default(true), // Caching active or not
    cacheKey: z.string().optional(), // Optional cache key for custom cache key generation if nothing is provided, the URL will be used as the cache key 
    duration: z.string(), // Cache duration as a string (e.g. "5s", "2h")
});

/**
 * Zod schema for global breezeCache configuration.
 * - redisUrl: Redis connection URL (required).
 * - enabled: Enable or disable caching globally.
 * - excludedPaths: Optional array of route prefixes to exclude from caching.
 * - debug: Optional flag to enable debug logging.
 */
export const breezeCacheConfigSchema = z.object({
    redisUrl: z.string().url(), // required Redis URL
    enabled: z.boolean().default(true), // Caching active or not
    excludedPaths: z.array(z.string()).optional(), // Optional: excluded routes for caching
    debug: z.boolean().optional(), // <-- Add debug flag
});

[...]
export function initializeCache() {
    const BreezeConfig = Config.get('breezeCache');
    const parseResult = breezeCacheConfigSchema.safeParse(BreezeConfig);
    [...]
}

                    

Ready to enhance your API?

Start using BreezeAPI plugins today and take your API to the next level.