Built-in Plugins
Minima.js comes with a set of pre-built plugins to handle common web development needs. These plugins can be easily integrated into your application:
- In module files - Use
meta.plugins(recommended) - In entry files - Use
app.register()
Quick Example
typescript
import { type Meta, type Routes } from "@minimajs/server";
import { cors } from "@minimajs/server/plugins";
// Apply CORS globally to all routes in this scope
export const meta: Meta = {
plugins: [cors({ origin: "*" })],
};
function getData() {
return { data: "value" };
}
export const routes: Routes = {
"GET /api/data": getData,
};Available Plugins
- Body Parser: For parsing incoming request bodies (e.g., JSON, text).
- CORS: For managing Cross-Origin Resource Sharing headers.
- Descriptor: For applying route metadata to entire scopes.
- Express Middleware: For integrating Express.js-style middleware (Node.js only).
- Proxy: For extracting client information from proxy headers (IP, protocol, hostname).
- Route Logger: A development utility to log all registered routes.
- Graceful Shutdown: For ensuring your server shuts down gracefully.