decentralised sync engine

feat: xrpc routes

serenity 4c7c1f5d fe69cc3a

Changed files
+39
src
lib
handlers
types
routes
xrpc
_health
systems.gmstn.development.lattice.getOwner
+9
src/lib/handlers/getOwnerDid.ts
···
+
import { OWNER_DID } from "@/lib/env";
+
import { getRegistrationState } from "@/lib/state";
+
import type { RouteHandler } from "@/lib/types/routes";
+
import { newSuccessResponse } from "@/lib/utils/http/responses";
+
+
export const getOwnerHandler: RouteHandler = () => {
+
const { registered } = getRegistrationState();
+
return newSuccessResponse({ registered, ownerDid: OWNER_DID });
+
};
+8
src/lib/types/http/responses.ts
···
+
import { didSchema } from "@/lib/types/atproto";
import {
latticeSessionInfoSchema,
shardSessionInfoSchema,
···
typeof shardHandshakeResponseSchema
>;
+
export const getOwnerDidResponseSchema = z.object({
+
registered: z.boolean(),
+
ownerDid: didSchema,
+
});
+
export type GetOwnerDidResponse = z.infer<typeof getOwnerDidResponseSchema>;
+
export const httpResponseDataSchema = z.union([
latticeHandshakeResponseSchema,
shardHandshakeResponseSchema,
+
getOwnerDidResponseSchema,
]);
export type HttpResponseData = z.infer<typeof httpResponseDataSchema>;
+5
src/routes/index.ts
···
import { didWebDocRoute } from "@/routes/dot-well-known/did-dot-json/route";
import { handshakeRoute } from "@/routes/handshake/route";
import { indexRoute } from "@/routes/route";
+
import { healthRoute } from "@/routes/xrpc/_health/route";
+
import { systemsGmstnDevelopmentShardGetOwnerRoute } from "@/routes/xrpc/systems.gmstn.development.lattice.getOwner/route";
export const routes: Record<string, Route | WsRoute> = {
"/": indexRoute,
"/.well-known/did.json": didWebDocRoute,
"/handshake": handshakeRoute,
"/connect": connectRoute,
+
"/xrpc/_health": healthRoute,
+
"/xrpc/systems.gmstn.development.lattice.getOwner":
+
systemsGmstnDevelopmentShardGetOwnerRoute,
};
+10
src/routes/xrpc/_health/route.ts
···
+
import type { Route } from "@/lib/types/routes";
+
+
export const healthRoute: Route = {
+
method: "GET",
+
handler: () => {
+
return new Response("this lattice is running at 0.0.1", {
+
headers: { "content-type": "text/plain; charset=utf-8" },
+
});
+
},
+
};
+7
src/routes/xrpc/systems.gmstn.development.lattice.getOwner/route.ts
···
+
import { getOwnerHandler } from "@/lib/handlers/getOwnerDid";
+
import type { Route } from "@/lib/types/routes";
+
+
export const systemsGmstnDevelopmentShardGetOwnerRoute: Route = {
+
method: "GET",
+
handler: getOwnerHandler,
+
};