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 com: ComNS 21 22 constructor(options?: XrpcOptions) { 23 this.xrpc = createXrpcServer(schemas, options) 24 this.app = new AppNS(this) 25 this.com = new ComNS(this) 26 } 27} 28 29export class AppNS { 30 _server: Server 31 bsky: AppBskyNS 32 33 constructor(server: Server) { 34 this._server = server 35 this.bsky = new AppBskyNS(server) 36 } 37} 38 39export class AppBskyNS { 40 _server: Server 41 actor: AppBskyActorNS 42 43 constructor(server: Server) { 44 this._server = server 45 this.actor = new AppBskyActorNS(server) 46 } 47} 48 49export class AppBskyActorNS { 50 _server: Server 51 52 constructor(server: Server) { 53 this._server = server 54 } 55} 56 57export class ComNS { 58 _server: Server 59 example: ComExampleNS 60 61 constructor(server: Server) { 62 this._server = server 63 this.example = new ComExampleNS(server) 64 } 65} 66 67export class ComExampleNS { 68 _server: Server 69 70 constructor(server: Server) { 71 this._server = server 72 } 73} 74 75type SharedRateLimitOpts<T> = { 76 name: string 77 calcKey?: (ctx: T) => string 78 calcPoints?: (ctx: T) => number 79} 80type RouteRateLimitOpts<T> = { 81 durationMs: number 82 points: number 83 calcKey?: (ctx: T) => string 84 calcPoints?: (ctx: T) => number 85} 86type HandlerOpts = { blobLimit?: number } 87type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T> 88type ConfigOf<Auth, Handler, ReqCtx> = 89 | Handler 90 | { 91 auth?: Auth 92 opts?: HandlerOpts 93 rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[] 94 handler: Handler 95 } 96type ExtractAuth<AV extends AuthVerifier | StreamAuthVerifier> = Extract< 97 Awaited<ReturnType<AV>>, 98 { credentials: unknown } 99>