Scratch space for learning atproto app development
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import {
5 createServer as createXrpcServer,
6 Server as XrpcServer,
7 Options as XrpcOptions,
8 AuthVerifier,
9 StreamAuthVerifier,
10} from '@atproto/xrpc-server'
11import { schemas } from './lexicons'
12
13export function createServer(options?: XrpcOptions): Server {
14 return new Server(options)
15}
16
17export class Server {
18 xrpc: XrpcServer
19 app: AppNS
20 xyz: XyzNS
21 com: ComNS
22
23 constructor(options?: XrpcOptions) {
24 this.xrpc = createXrpcServer(schemas, options)
25 this.app = new AppNS(this)
26 this.xyz = new XyzNS(this)
27 this.com = new ComNS(this)
28 }
29}
30
31export class AppNS {
32 _server: Server
33 bsky: AppBskyNS
34
35 constructor(server: Server) {
36 this._server = server
37 this.bsky = new AppBskyNS(server)
38 }
39}
40
41export class AppBskyNS {
42 _server: Server
43 actor: AppBskyActorNS
44
45 constructor(server: Server) {
46 this._server = server
47 this.actor = new AppBskyActorNS(server)
48 }
49}
50
51export class AppBskyActorNS {
52 _server: Server
53
54 constructor(server: Server) {
55 this._server = server
56 }
57}
58
59export class XyzNS {
60 _server: Server
61 statusphere: XyzStatusphereNS
62
63 constructor(server: Server) {
64 this._server = server
65 this.statusphere = new XyzStatusphereNS(server)
66 }
67}
68
69export class XyzStatusphereNS {
70 _server: Server
71
72 constructor(server: Server) {
73 this._server = server
74 }
75}
76
77export class ComNS {
78 _server: Server
79 atproto: ComAtprotoNS
80
81 constructor(server: Server) {
82 this._server = server
83 this.atproto = new ComAtprotoNS(server)
84 }
85}
86
87export class ComAtprotoNS {
88 _server: Server
89 repo: ComAtprotoRepoNS
90
91 constructor(server: Server) {
92 this._server = server
93 this.repo = new ComAtprotoRepoNS(server)
94 }
95}
96
97export class ComAtprotoRepoNS {
98 _server: Server
99
100 constructor(server: Server) {
101 this._server = server
102 }
103}
104
105type SharedRateLimitOpts<T> = {
106 name: string
107 calcKey?: (ctx: T) => string
108 calcPoints?: (ctx: T) => number
109}
110type RouteRateLimitOpts<T> = {
111 durationMs: number
112 points: number
113 calcKey?: (ctx: T) => string
114 calcPoints?: (ctx: T) => number
115}
116type HandlerOpts = { blobLimit?: number }
117type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T>
118type ConfigOf<Auth, Handler, ReqCtx> =
119 | Handler
120 | {
121 auth?: Auth
122 opts?: HandlerOpts
123 rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[]
124 handler: Handler
125 }
126type ExtractAuth<AV extends AuthVerifier | StreamAuthVerifier> = Extract<
127 Awaited<ReturnType<AV>>,
128 { credentials: unknown }
129>