Graphical PDS migrator for AT Protocol
1import { getMigrationState } from "../../lib/migration-state.ts";
2import { define } from "../../utils.ts";
3
4/**
5 * API endpoint to check the current migration state.
6 * Returns the migration state information including whether migrations are allowed.
7 */
8export const handler = define.handlers({
9 GET(_ctx) {
10 try {
11 const stateInfo = getMigrationState();
12
13 return new Response(
14 JSON.stringify({
15 state: stateInfo.state,
16 message: stateInfo.message,
17 allowMigration: stateInfo.allowMigration,
18 }),
19 {
20 status: 200,
21 headers: {
22 "Content-Type": "application/json",
23 },
24 }
25 );
26 } catch (error) {
27 console.error("Error checking migration state:", error);
28
29 return new Response(
30 JSON.stringify({
31 state: "issue",
32 message: "Unable to determine migration state. Please try again later.",
33 allowMigration: false,
34 }),
35 {
36 status: 500,
37 headers: {
38 "Content-Type": "application/json",
39 },
40 }
41 );
42 }
43 },
44});