Skip to content

Middleware

Probun has a middleware system that allows you to run code before and after each route.

Creating Middleware

import type { Next } from 'probun';
const myMiddleware = async (req: Request, next: Next) => {
console.log('My Middleware');
};

Using Middleware

import { Probun } from 'probun';
import { myMiddleware } from './middleware';
Probun({
port: 3000,
routes: 'routes',
middleware: [myMiddleware],
});