halkyon/apps/meditate/halkyon_meditate_server/lib/server.dart
Tizian 「ティツィアーン」 929974443d
feat(meditate): the operator's library on the server, and a course's lessons done synced
An operator's folder (MEDITATE_LIBRARY_DIR) of recordings, pictures and a
YAML manifest, library.yaml (commented sample: library.example.yaml), read
as the server starts and every ten minutes, held in memory. Items without
a licence or credit, files outside the folder, unknown categories and
courses pointing at items not served are refused and logged; a manifest
that doesn't read keeps the library served before. bin/check_library.dart
checks a folder before deploying.

The catalogue goes to signed-in people alone (LibraryEndpoint), with a
12-hour access the server signs; the web server's /library/<served name>
serves the files to that access only, by ranges (relic's StaticHandler).
No request path reaches the file system.

lesson_done: a lesson done, sealed and synced, a row each; the migration
creates the table with its spaceId index and the cascading foreign key to
the sync engine's spaces, as dream's did. ADR 0038, D16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
2026-11-04 09:31:59 +01:00

41 lines
1.6 KiB
Dart

import 'package:halkyon_base_server/base.dart';
import 'package:halkyon_meditate_server/src/generated/serverpod.dart';
import 'package:halkyon_meditate_server/src/library/meditate_library.dart';
import 'package:halkyon_meditate_server/src/meditate_base.dart';
import 'package:halkyon_meditate_server/src/pruning.dart';
import 'package:serverpod_auth_idp_server/core.dart';
/// The starting point of Halkyon Meditate's server.
Future<void> run(List<String> args) async {
// The generated Serverpod is already connected with the generated code.
final pod = Serverpod(args);
// What every Halkyon server has (ADR 0014): sign-in, the account and its
// deletion, the pruning, the instance's basics, set up for Meditate; a member
// of the instance's register where the operator names one (ADR 0016).
HalkyonBase.configure(
pod,
meditateBase(accounts: AccountsMode.fromEnvironment()),
);
// Token managers validate and issue authentication keys; identity
// providers are the ways people can sign in (halkyon_base's
// auth_config.dart).
pod.initializeAuthServices(
tokenManagerBuilders: tokenManagerBuilders,
identityProviderBuilders: identityProviderBuilders(pod),
);
// The calls between the instance's services, on the web server
// (ADR 0016); Caddy never forwards them.
addInstanceRoutes(pod);
// The operator's library's files, to devices holding an access the
// catalogue gave them (ADR 0038, D16).
addLibraryRoute(pod);
await pod.start();
await schedulePruning(pod);
// The operator's library, read now and again every ten minutes (D16).
await startLibrary(pod);
}