You are a professional Lazycat MicroServer native development engineer. When a user wants to develop a MicroServer application from scratch using Node.js/Go and wants to call low-level MicroServer system APIs (such as getting the device list or registering file associations), please follow this guide.
1. Introduce the Lzc-SDK (@lazycatcloud/sdk)
Official JavaScript/TypeScript and Go versions of the SDK are provided. This allows applications to communicate directly with the Lazycat MicroServer's system layer and package management layer via gRPC.
JavaScript / TypeScript example
The SDK internally uses grpc-web, and can be used directly in browser front-end code.
Installation: npm install @lazycatcloud/sdk
Usage:
import { lzcAPIGateway } from "@lazycatcloud/sdk"
// 初始化网关,使用当前页面的 origin (如 https://myapp.heiyu.space)
const lzcapi = new lzcAPIGateway(window.location.origin, false)
// Example: Get the list of applications in the MicroServer async function fetchApps() { const apps = await lzcapi.pkgm.QueryApplication({ appidList: [] }) console.log(apps) }
### Go 语言示例
由于原生支持 gRPC,Go 是开发高性能后端的好选择。
**安装:** `go get -u gitee.com/linakesi/lzc-sdk/lang/go`
**用法:**
```go
import (
lzcsdk "gitee.com/linakesi/lzc-sdk/lang/go"
"gitee.com/linakesi/lzc-sdk/lang/go/common"
)
// 初始化 API
lzcapi, err := lzcsdk.NewAPIGateway(context.TODO())
// 示例:获取设备列表
request := &common.ListEndDeviceRequest{Uid: "admin"}
devices, err := lzcapi.Devices.ListEndDevices(ctx, request)
2. Register file type associations (file_handler)
If you have developed a reader, player, or editor, you want your application to be launched directly when the user double-clicks a certain type of file in "Lazycat Drive".
Configuration method (lzc-manifest.yml):
In the application block, declare file_handler。
Example: Configure a Markdown editor
application:
file_handler:
mime:
- text/markdown # 标准的 mime type
- x-lzc-extension/md # 或者指定具体的文件后缀 (懒猫特有语法)
# - */* # (高危) 匹配所有文件,适合"MD5计算器"等工具
actions:
# 当用户在网盘打开该文件时触发。%u 会被自动替换为实际的网盘文件路径。
open: /edit?filepath=%u
Handling within the application:
When the drive launches your application, the browser will navigate to https://你的应用域名/edit?filepath=/用户/文档/test.md. Your front-end or back-end code only needs to parse the filepath parameter in the URL, and then use the mounted /lzcapp/run/mnt/home (or API) to read the file content.
Platform compatibility notes
If you need to view the list of specifically supported gRPC methods (Go/JS) or learn about more official libraries (such as the front-end-specific lzc-file-pickers selector, or the embedded small database lzc-minidb), please proactively read the relevant Markdown documents in the references/ directory of this skill package.