Micro API
Micro API is a radically simplified template for building microservices with minimal boilerplate. Inspired by modern frameworks like Hono and Elysia, it focuses on pure simplicity while giving you access to the rest of @expressots/adapter-express when you need it.
What you get
| Feature | Default |
|---|---|
| Three-line startup | micro(), app.get(...), app.listen(...) |
| Auto-response | Return a string, object, or array; the framework calls res.send / res.json for you |
| Auto JSON parsing | On by default |
| Express middleware | Drop in any RequestHandler |
| Studio Agent | Auto-enabled in development when the package is installed |
| Opt-in service mesh | CircuitBreaker, ServiceClient, ServiceDiscovery, ServiceProxy (separate imports) |
Getting Started
Create a New Micro API Project
expressots new my-api --template micro
Minimal Example
import { micro } from "@expressots/adapter-express";
const app = micro();
app.get("/", () => "Hello World");
app.listen(3000);
That's it! Three lines to a working API.
Project Structure
my-api/
├── src/
│ └── api.ts # Main entry point
├── test/
│ └── api.spec.ts
├── Dockerfile
├── docker-compose.yml
├── package.json
├── tsconfig.json
└── expressots.config.ts
Basic Usage
The entire application is defined in a single file:
// src/api.ts
import { micro } from "@expressots/adapter-express";
const app = micro();
// Return objects - automatically JSON serialized
app.get("/", () => ({
name: "ExpressoTS Micro",
version: "4.0.0",
message: "Hello from ExpressoTS Micro API!",
}));
// Return strings - sent as text
app.get("/text", () => "Hello World");
// Health check
app.get("/health", () => ({
status: "healthy",
timestamp: new Date().toISOString(),
uptime: process.uptime(),
}));
// Start server
app.listen(3000);
Configuration
The micro() function accepts an optional configuration object:
const app = micro({
autoParseJson: true, // Enable JSON parsing (default: true)
globalPrefix: "/api", // Prefix all routes with /api
showBanner: true, // Show startup banner (default: true)
});
Route Definition
HTTP Methods
app.get("/path", handler);
app.post("/path", handler);
app.put("/path", handler);
app.patch("/path", handler);
app.delete("/path", handler);