跳转到内容

Quick Start

此内容尚不支持你的语言。

This guide will help you start MiniGateway and make your first API proxy request.

Terminal window
# Install MiniGateway
npm install -g @minigateway/cli
# Start the server
minigateway start
# Or with custom options
minigateway start --port 8080 --log-level debug

The server will start and display:

╔════════════════════════════════════════════════════════════╗
║ MiniGateway ║
╠════════════════════════════════════════════════════════════╣
║ Server: http://localhost:8080 ║
║ ║
║ Endpoints: ║
║ - Web UI: http://localhost:8080/ui ║
║ - Admin API: http://localhost:8080/admin ║
║ - Proxy: http://localhost:8080/ (via routes) ║
╚════════════════════════════════════════════════════════════╝

Create a configuration template:

Terminal window
# Create default config file
minigateway init
# View the generated config
cat ~/Library/Application\ Support/minigateway/config.yaml # macOS
cat ~/.config/minigateway/config.yaml # Linux

Use the Admin API or CLI to create a service:

Terminal window
# Via CLI
minigateway admin services create --name "my-api" --url "https://httpbin.org"
# Via Admin API
curl -X POST http://localhost:8080/admin/services \
-H "Content-Type: application/json" \
-d '{"name": "my-api", "url": "https://httpbin.org"}'
Terminal window
# Via CLI
minigateway admin routes create \
--service-id "<service-id>" \
--path "/api/*" \
--methods "GET,POST"
# Via Admin API
curl -X POST http://localhost:8080/admin/routes \
-H "Content-Type: application/json" \
-d '{"service_id": "<service-id>", "path": "/api/*", "methods": ["GET", "POST"]}'
Terminal window
# Request through the proxy
curl http://localhost:8080/api/get
OptionDescriptionDefault
--portServer port8080
--dbDatabase file pathPlatform-specific
--log-levelLog verbosity (debug, info, warn, error)info
--no-uiDisable Web UIfalse
--ui-distCustom UI dist pathauto-detected
VariableDescription
MINIGATEWAY_LOG_LEVELDefault log level
MINIGATEWAY_UI_DISTWeb UI dist path