micro

Консультации по micro, асинхронному фреймворку HTTP-микросервисов от Vercel. Нужен для лёгких HTTP-серверов, API-эндпоинтов и микросервисов на библиотеке micro.

Установка

$npx skills add https://github.com/openai/plugins/tree/5fd93af4cd0c623e020d0cc7e9ce178b4ac1f70f/plugins/vercel/skills/micro

Ставит скилл в текущий проект - CLI спросит, для каких агентов. С флагом -g - в домашнюю папку, для всех проектов. Другие способы

Описание автора

Expert guidance for micro — asynchronous HTTP microservices framework by Vercel. Use when building lightweight HTTP servers, API endpoints, or microservices using the micro library.

micro — Asynchronous HTTP Microservices

You are an expert in micro, Vercel's lightweight framework for building asynchronous HTTP microservices in Node.js. micro makes it easy to write single-purpose HTTP endpoints with minimal boilerplate.

Installation

npm install micro

Basic Usage

Create a module that exports a request handler:

// index.ts
import { serve } from 'micro'

const handler = (req: Request) => {
  return new Response('Hello, World!')
}

serve(handler)

Or use the classic API:

import { IncomingMessage, ServerResponse } from 'http'

export default (req: IncomingMessage, res: ServerResponse) => {
  res.end('Hello, World!')
}

Run with:

npx micro

Core API

json(req) — Parse JSON Body

import { json } from 'micro'

export default async (req: IncomingMessage, res: ServerResponse) => {
  const body = await json(req)
  return { received: body }
}

text(req) — Parse Text Body

import { text } from 'micro'

export default async (req: IncomingMessage, res: ServerResponse) => {
  const body = await text(req)
  return `You said: ${body}`
}

buffer(req) — Parse Raw Body

import { buffer } from 'micro'

export default async (req: IncomingMessage, res: ServerResponse) => {
  const raw = await buffer(req)
  return `Received ${raw.length} bytes`
}

send(res, statusCode, data) — Send Response

import { send } from 'micro'

export default (req: IncomingMessage, res: ServerResponse) => {
  send(res, 200, { status: 'ok' })
}

createError(statusCode, message) — HTTP Errors

import { createError } from 'micro'

export default (req: IncomingMessage, res: ServerResponse) => {
  if (!req.headers.authorization) {
    throw createError(401, 'Unauthorized')
  }
  return { authorized: true }
}

Development with micro-dev

micro-dev provides hot-reloading for development:

npm install --save-dev micro-dev

# Run in dev mode
npx micro-dev index.js

Composition

Chain multiple handlers with function composition:

import { IncomingMessage, ServerResponse } from 'http'

const cors = (fn: Function) => async (req: IncomingMessage, res: ServerResponse) => {
  res.setHeader('Access-Control-Allow-Origin', '*')
  return fn(req, res)
}

const handler = async (req: IncomingMessage, res: ServerResponse) => {
  return { hello: 'world' }
}

export default cors(handler)

package.json Setup

{
  "main": "index.js",
  "scripts": {
    "start": "micro",
    "dev": "micro-dev"
  },
  "dependencies": {
    "micro": "^10.0.0"
  },
  "devDependencies": {
    "micro-dev": "^3.0.0"
  }
}

Key Points

  1. Return values are sent as responses — return strings, objects (auto-serialized to JSON), or Buffers
  2. Async by default — handlers can be async functions, errors are caught automatically
  3. Thrown errors become HTTP errors — use createError() for proper status codes
  4. No routing built-in — micro is a single-endpoint server; use a router like micro-router for multi-route services
  5. Body parsing is explicit — use json(), text(), or buffer() to parse request bodies
  6. Composable — wrap handlers with higher-order functions for middleware-like behavior

Official Resources

Ещё из openai/plugins

Все 536
  1. agents-sdkв один кликагенты на Cloudflare Workers через Agents SDK
  2. android-emulator-qaв один кликпроверка Android-сценариев в эмуляторе
  3. build-chatgpt-appв один кликприложения ChatGPT на Apps SDK
  4. chatgpt-app-submissionв один кликподготовка ChatGPT-приложения к ревью
  5. cloudflareв один кликплатформа Cloudflare: Workers, D1, R2
  6. earnings-previewв один кликпревью отчётности компании
  7. notion-knowledge-captureв один кликрешения из чатов в страницы Notion
  8. notion-meeting-intelligenceв один кликподготовка к встречам по Notion

Похожие скиллы

Бэкенд и API
  1. claude-apianthropics/skillsприложения на основе Claude API
  2. aspnet-coreopenai/skillsразработка на ASP.NET Core
  3. Fullstack Dev Skillsjeffallan/claude-skillsнабор из 67 скиллов для фулстека
  4. xberg-io/xbergxberg-io/xbergизвлечение данных из 107 форматов
  5. cli-creatoropenai/skillsсоздание CLI для Codex
  6. api-design-principleswshobson/agentsпроектирование REST и GraphQL API
  7. czlonkowski/n8n-code-javascriptczlonkowski/n8n-skillsкод на JavaScript в нодах n8n
  8. architecture-decision-recordswshobson/agentsзаписи архитектурных решений (ADR)