grain.social is a photo sharing platform built on atproto.
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import {
5 createServer as createXrpcServer,
6 Server as XrpcServer,
7 type Options as XrpcOptions,
8 type AuthVerifier,
9 type StreamAuthVerifier,
10} from "npm:@atproto/xrpc-server"
11import { schemas } from './lexicons.ts'
12import * as ComAtprotoLabelSubscribeLabels from './types/com/atproto/label/subscribeLabels.ts'
13import * as ComAtprotoLabelQueryLabels from './types/com/atproto/label/queryLabels.ts'
14
15export function createServer(options?: XrpcOptions): Server {
16 return new Server(options)
17}
18
19export class Server {
20 xrpc: XrpcServer
21 com: ComNS
22
23 constructor(options?: XrpcOptions) {
24 this.xrpc = createXrpcServer(schemas, options)
25 this.com = new ComNS(this)
26 }
27}
28
29export class ComNS {
30 _server: Server
31 atproto: ComAtprotoNS
32
33 constructor(server: Server) {
34 this._server = server
35 this.atproto = new ComAtprotoNS(server)
36 }
37}
38
39export class ComAtprotoNS {
40 _server: Server
41 label: ComAtprotoLabelNS
42
43 constructor(server: Server) {
44 this._server = server
45 this.label = new ComAtprotoLabelNS(server)
46 }
47}
48
49export class ComAtprotoLabelNS {
50 _server: Server
51
52 constructor(server: Server) {
53 this._server = server
54 }
55
56 subscribeLabels<AV extends StreamAuthVerifier>(
57 cfg: ConfigOf<
58 AV,
59 ComAtprotoLabelSubscribeLabels.Handler<ExtractAuth<AV>>,
60 ComAtprotoLabelSubscribeLabels.HandlerReqCtx<ExtractAuth<AV>>
61 >,
62 ) {
63 const nsid = 'com.atproto.label.subscribeLabels' // @ts-ignore
64 return this._server.xrpc.streamMethod(nsid, cfg)
65 }
66
67 queryLabels<AV extends AuthVerifier>(
68 cfg: ConfigOf<
69 AV,
70 ComAtprotoLabelQueryLabels.Handler<ExtractAuth<AV>>,
71 ComAtprotoLabelQueryLabels.HandlerReqCtx<ExtractAuth<AV>>
72 >,
73 ) {
74 const nsid = 'com.atproto.label.queryLabels' // @ts-ignore
75 return this._server.xrpc.method(nsid, cfg)
76 }
77}
78
79type SharedRateLimitOpts<T> = {
80 name: string
81 calcKey?: (ctx: T) => string | null
82 calcPoints?: (ctx: T) => number
83}
84type RouteRateLimitOpts<T> = {
85 durationMs: number
86 points: number
87 calcKey?: (ctx: T) => string | null
88 calcPoints?: (ctx: T) => number
89}
90type HandlerOpts = { blobLimit?: number }
91type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T>
92type ConfigOf<Auth, Handler, ReqCtx> =
93 | Handler
94 | {
95 auth?: Auth
96 opts?: HandlerOpts
97 rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[]
98 handler: Handler
99 }
100type ExtractAuth<AV extends AuthVerifier | StreamAuthVerifier> = Extract<
101 Awaited<ReturnType<AV>>,
102 { credentials: unknown }
103>