{"library":"micri","title":"Micri Microservices Framework","description":"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install micri"],"cli":null},"imports":["import { serve } from 'micri';","import { buffer, text, json } from 'micri';","import { Router } from 'micri';","import { Router } from 'micri'; const myRouter = Router.router(...);","import { on } from 'micri';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { serve } from 'micri';\nimport { ServerResponse, IncomingMessage, Server } from 'http';\n\nconst sleep = (ms: number): Promise<void> => new Promise((r) => setTimeout(r, ms));\n\ninterface CustomRequest extends IncomingMessage {\n  // Micri handlers receive native Node.js http.IncomingMessage\n  // You can extend it for custom properties if needed.\n}\n\nconst handler = async (req: CustomRequest, res: ServerResponse): Promise<string> => {\n  // Simulate an asynchronous operation, e.g., database call or external API fetch\n  await sleep(500);\n  \n  // Micri handlers can return a string, Buffer, or Stream directly to send as the response body.\n  return `Hello from Micri! You accessed: ${req.url}`;\n};\n\nconst PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;\nconst server: Server = serve(handler);\n\nserver.listen(PORT, () => {\n  console.log(`Micri server listening on http://localhost:${PORT}`);\n  console.log('Try opening http://localhost:3000/hello or http://localhost:3000/world in your browser.');\n});\n","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}