decentralised sync engine
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: xrpc routes

serenity 4c7c1f5d fe69cc3a

+39
+9
src/lib/handlers/getOwnerDid.ts
··· 1 + import { OWNER_DID } from "@/lib/env"; 2 + import { getRegistrationState } from "@/lib/state"; 3 + import type { RouteHandler } from "@/lib/types/routes"; 4 + import { newSuccessResponse } from "@/lib/utils/http/responses"; 5 + 6 + export const getOwnerHandler: RouteHandler = () => { 7 + const { registered } = getRegistrationState(); 8 + return newSuccessResponse({ registered, ownerDid: OWNER_DID }); 9 + };
+8
src/lib/types/http/responses.ts
··· 1 + import { didSchema } from "@/lib/types/atproto"; 1 2 import { 2 3 latticeSessionInfoSchema, 3 4 shardSessionInfoSchema, ··· 28 29 typeof shardHandshakeResponseSchema 29 30 >; 30 31 32 + export const getOwnerDidResponseSchema = z.object({ 33 + registered: z.boolean(), 34 + ownerDid: didSchema, 35 + }); 36 + export type GetOwnerDidResponse = z.infer<typeof getOwnerDidResponseSchema>; 37 + 31 38 export const httpResponseDataSchema = z.union([ 32 39 latticeHandshakeResponseSchema, 33 40 shardHandshakeResponseSchema, 41 + getOwnerDidResponseSchema, 34 42 ]); 35 43 export type HttpResponseData = z.infer<typeof httpResponseDataSchema>; 36 44
+5
src/routes/index.ts
··· 3 3 import { didWebDocRoute } from "@/routes/dot-well-known/did-dot-json/route"; 4 4 import { handshakeRoute } from "@/routes/handshake/route"; 5 5 import { indexRoute } from "@/routes/route"; 6 + import { healthRoute } from "@/routes/xrpc/_health/route"; 7 + import { systemsGmstnDevelopmentShardGetOwnerRoute } from "@/routes/xrpc/systems.gmstn.development.lattice.getOwner/route"; 6 8 7 9 export const routes: Record<string, Route | WsRoute> = { 8 10 "/": indexRoute, 9 11 "/.well-known/did.json": didWebDocRoute, 10 12 "/handshake": handshakeRoute, 11 13 "/connect": connectRoute, 14 + "/xrpc/_health": healthRoute, 15 + "/xrpc/systems.gmstn.development.lattice.getOwner": 16 + systemsGmstnDevelopmentShardGetOwnerRoute, 12 17 };
+10
src/routes/xrpc/_health/route.ts
··· 1 + import type { Route } from "@/lib/types/routes"; 2 + 3 + export const healthRoute: Route = { 4 + method: "GET", 5 + handler: () => { 6 + return new Response("this lattice is running at 0.0.1", { 7 + headers: { "content-type": "text/plain; charset=utf-8" }, 8 + }); 9 + }, 10 + };
+7
src/routes/xrpc/systems.gmstn.development.lattice.getOwner/route.ts
··· 1 + import { getOwnerHandler } from "@/lib/handlers/getOwnerDid"; 2 + import type { Route } from "@/lib/types/routes"; 3 + 4 + export const systemsGmstnDevelopmentShardGetOwnerRoute: Route = { 5 + method: "GET", 6 + handler: getOwnerHandler, 7 + };