feat(import): admin UI at /admin/import, dev server, extraction cleanup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9f96e293e1
commit
90a477691b
@@ -0,0 +1,23 @@
|
||||
// Dev server for the import UI while real sign-in (learner package) is not merged: everyone is the owner.
|
||||
// Usage: STC_PORT=3462 STC_DATA_DIR=/tmp/stc-import-data STC_PYTHON=… bun packages/feature-import/dev/serve.ts
|
||||
import { resolve } from "node:path";
|
||||
import type { AuthService, ServerContext } from "@stc/contracts";
|
||||
import { createApp, createJobQueue, loadConfig } from "@stc/core";
|
||||
import { createCourseRepository } from "@stc/course-format";
|
||||
import { connect, migrate } from "@stc/db";
|
||||
import indexHtml from "../../../apps/web/index.html";
|
||||
import { importFeature } from "../src";
|
||||
|
||||
const config = loadConfig();
|
||||
config.courseDirs.push(resolve(config.dataDir, "courses"));
|
||||
const db = await connect(config.databaseUrl);
|
||||
await migrate(db);
|
||||
const auth: AuthService = { userFromRequest: async () => ({ id: "dev", email: "dev@localhost", name: "Dev owner", roles: ["owner"], groups: [] }) };
|
||||
const ctx = { config, db, courses: await createCourseRepository(config.courseDirs), auth } as ServerContext;
|
||||
const feature = importFeature(ctx);
|
||||
const jobs = createJobQueue(db, feature.jobs!);
|
||||
ctx.jobs = jobs;
|
||||
const app = createApp(ctx, [feature]);
|
||||
jobs.start();
|
||||
const server = Bun.serve({ port: config.port, routes: { ...app.routes, "/api/*": (req) => app.fetch(req), "/*": indexHtml }, fetch: (req) => app.fetch(req) });
|
||||
console.log(`import dev server on ${server.url}`);
|
||||
Reference in New Issue
Block a user