BetterFrame/server/src/plugins/service-api-http/index.ts

63 lines
1.6 KiB
TypeScript
Raw Normal View History

2026-05-09 23:09:13 +00:00
/**
* service-api-http h3 listener for kiosk-facing REST API.
2026-05-09 23:09:13 +00:00
*
* Serves pairing, bundle, and kiosk management endpoints.
* Port 18081 behind Angie proxy.
2026-05-09 23:09:13 +00:00
*/
import * as av from "@anyvali/js";
import {
BSBService,
type BSBServiceConstructor,
createConfigSchema,
createEventSchemas,
type Observable,
} from "@bsb/base";
const ConfigSchema = av.object(
{
host: av.string().default("127.0.0.1"),
port: av.int().min(1).max(65535).default(18081),
codeTtlSeconds: av.int().min(60).max(3600).default(600),
2026-05-09 23:09:13 +00:00
},
{ unknownKeys: "strip" },
);
export const Config = createConfigSchema(
{
name: "service-api-http",
description: "h3 HTTP server for kiosk-facing REST API.",
tags: ["service", "http", "api", "kiosk"],
},
ConfigSchema,
);
export const EventSchemas = createEventSchemas({
emitEvents: {},
onEvents: {},
emitReturnableEvents: {},
onReturnableEvents: {},
emitBroadcast: {},
onBroadcast: {},
});
export class Plugin extends BSBService<InstanceType<typeof Config>, typeof EventSchemas> {
static override Config = Config;
static override EventSchemas = EventSchemas;
initBeforePlugins?: string[];
initAfterPlugins?: string[] = ["service-store"];
2026-05-09 23:09:13 +00:00
runBeforePlugins?: string[];
runAfterPlugins?: string[];
constructor(cfg: BSBServiceConstructor<InstanceType<typeof Config>, typeof EventSchemas>) {
super(cfg);
}
async init(_obs: Observable): Promise<void> {
// TODO: create h3 app, mount kiosk + pairing routes
2026-05-09 23:09:13 +00:00
}
async run(_obs: Observable): Promise<void> {}
async dispose(): Promise<void> {}
2026-05-09 23:09:13 +00:00
}