|
| 1 | +# @landscape-router/types |
| 2 | + |
| 3 | +TypeScript API client and type definitions for [Landscape Router](https://github.com/ThisSeanZhang/landscape), auto-generated from OpenAPI spec via [orval](https://orval.dev/). |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install @landscape-router/types |
| 9 | +# or |
| 10 | +pnpm add @landscape-router/types |
| 11 | +``` |
| 12 | + |
| 13 | +Requires `axios` as a peer dependency: |
| 14 | + |
| 15 | +```bash |
| 16 | +npm install axios |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +### 1. Configure axios instance |
| 22 | + |
| 23 | +Before calling any API function, you must set up the axios instance: |
| 24 | + |
| 25 | +```ts |
| 26 | +import axios from "axios"; |
| 27 | +import { setAxiosInstance } from "@landscape-router/types/mutator"; |
| 28 | + |
| 29 | +const instance = axios.create({ |
| 30 | + baseURL: "https://your-landscape-router:6443", |
| 31 | + timeout: 30000, |
| 32 | +}); |
| 33 | + |
| 34 | +setAxiosInstance(instance); |
| 35 | +``` |
| 36 | + |
| 37 | +### 2. Call API functions |
| 38 | + |
| 39 | +```ts |
| 40 | +import { getFlowRules } from "@landscape-router/types/api/flow-rules/flow-rules"; |
| 41 | +import { getDnsRule } from "@landscape-router/types/api/dns-rules/dns-rules"; |
| 42 | + |
| 43 | +// Fetch all flow rules |
| 44 | +const flows = await getFlowRules(); |
| 45 | + |
| 46 | +// Fetch a specific DNS rule |
| 47 | +const rule = await getDnsRule("my-rule-id"); |
| 48 | +``` |
| 49 | + |
| 50 | +### 3. Use type definitions |
| 51 | + |
| 52 | +```ts |
| 53 | +import type { FlowConfig, DnsUpstreamConfig } from "@landscape-router/types/api/schemas"; |
| 54 | +``` |
| 55 | + |
| 56 | +## Available API Modules |
| 57 | + |
| 58 | +| Module | Import Path | |
| 59 | +|--------|-------------| |
| 60 | +| Auth | `@landscape-router/types/api/auth/auth` | |
| 61 | +| DNS Rules | `@landscape-router/types/api/dns-rules/dns-rules` | |
| 62 | +| DNS Redirects | `@landscape-router/types/api/dns-redirects/dns-redirects` | |
| 63 | +| DNS Service | `@landscape-router/types/api/dns-service/dns-service` | |
| 64 | +| DNS Upstreams | `@landscape-router/types/api/dns-upstreams/dns-upstreams` | |
| 65 | +| DHCPv4 | `@landscape-router/types/api/dhcpv4/dhcpv4` | |
| 66 | +| Docker | `@landscape-router/types/api/docker/docker` | |
| 67 | +| Docker Images | `@landscape-router/types/api/docker-images/docker-images` | |
| 68 | +| Docker Networks | `@landscape-router/types/api/docker-networks/docker-networks` | |
| 69 | +| Enrolled Devices | `@landscape-router/types/api/enrolled-devices/enrolled-devices` | |
| 70 | +| Firewall Blacklists | `@landscape-router/types/api/firewall-blacklists/firewall-blacklists` | |
| 71 | +| Firewall Service | `@landscape-router/types/api/firewall-service/firewall-service` | |
| 72 | +| Flow Rules | `@landscape-router/types/api/flow-rules/flow-rules` | |
| 73 | +| Geo IPs | `@landscape-router/types/api/geo-ips/geo-ips` | |
| 74 | +| Geo Sites | `@landscape-router/types/api/geo-sites/geo-sites` | |
| 75 | +| ICMPv6 RA | `@landscape-router/types/api/icmpv6-ra/icmpv6-ra` | |
| 76 | +| Interfaces | `@landscape-router/types/api/interfaces/interfaces` | |
| 77 | +| IP Config | `@landscape-router/types/api/ip-config/ip-config` | |
| 78 | +| IPv6 PD | `@landscape-router/types/api/ipv6-pd/ipv6-pd` | |
| 79 | +| Metric | `@landscape-router/types/api/metric/metric` | |
| 80 | +| MSS Clamp | `@landscape-router/types/api/mss-clamp/mss-clamp` | |
| 81 | +| NAT Service | `@landscape-router/types/api/nat-service/nat-service` | |
| 82 | +| PPPoE | `@landscape-router/types/api/pppo-e/pppo-e` | |
| 83 | +| Route | `@landscape-router/types/api/route/route` | |
| 84 | +| Route LAN | `@landscape-router/types/api/route-lan/route-lan` | |
| 85 | +| Route WAN | `@landscape-router/types/api/route-wan/route-wan` | |
| 86 | +| Static NAT Mappings | `@landscape-router/types/api/static-nat-mappings/static-nat-mappings` | |
| 87 | +| System Config | `@landscape-router/types/api/system-config/system-config` | |
| 88 | +| System Info | `@landscape-router/types/api/system-info/system-info` | |
| 89 | +| Wi-Fi | `@landscape-router/types/api/wi-fi/wi-fi` | |
| 90 | +| Destination IP Rules | `@landscape-router/types/api/destination-ip-rules/destination-ip-rules` | |
| 91 | +| Schemas (types only) | `@landscape-router/types/api/schemas` | |
| 92 | + |
| 93 | +## License |
| 94 | + |
| 95 | +[MIT](https://github.com/ThisSeanZhang/landscape/blob/main/LICENSE) |
0 commit comments