Micri is a lightweight, asynchronous HTTP microservices library for Node.js, currently at version 4.5.1. It provides a minimal yet high-performance foundation for building single-purpose HTTP functions, emphasizing explicit control over request handling. Key differentiators include its small codebase (~500 lines), opt-in JSON parsing for speed, and strong integration with `async`/`await` patterns for easy asynchronous operations. Unlike larger frameworks, Micri deliberately avoids middleware, requiring developers to explicitly declare and handle all dependencies within their request handlers. Its standard HTTP approach and agility make it suitable for containerized and serverless deployments. The project has a stable release cadence, with recent major updates addressing Node.js compatibility and core feature enhancements.
npm install micriVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates creating a basic Micri HTTP server using the `serve` function, handling an asynchronous request, and listening on a specified port. It highlights Micri's `async`/`await` focus for simple handlers.
Upgrade your Node.js environment to version 12.0.0 or later. Using an active LTS version (e.g., Node.js 18 or 20) is recommended.
Implement shared logic as utility functions or compose your handlers by wrapping them with higher-order functions to apply common behaviors.
Always use the provided `buffer`, `text`, or `json` utility functions and await their results to parse the request body. Ensure you call these functions only once per request to avoid errors.
Arrange your routes from the most specific to the least specific. Consider using `on.otherwise()` as the final route to gracefully handle any requests that do not match preceding rules.
Replace all `const { symbol } = require('micri');` statements with `import { symbol } from 'micri';` for Micri imports in your ES module files.Micri handlers operate directly with native Node.js `http.ServerResponse`. To send data, either return a string, Buffer, or Stream from your handler, or use `res.end()` for direct manipulation. For example, `return 'Hello World';` or `res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({ message: 'Hello' })); return;`.Call body parsing functions only once per request. Store the result in a variable and reuse it throughout your handler to access the parsed body data. For example, `const requestBody = await json(req);`
No dependency data recorded yet.