An experimental TypeSpec syntax for Lexicon
1/**
2 * GENERATED CODE - DO NOT MODIFY
3 */
4import {
5 type Auth,
6 type Options as XrpcOptions,
7 Server as XrpcServer,
8 type StreamConfigOrHandler,
9 type MethodConfigOrHandler,
10 createServer as createXrpcServer,
11} from '@atproto/xrpc-server'
12import { schemas } from './lexicons.js'
13import * as XyzStatusphereGetStatuses from './types/xyz/statusphere/getStatuses.js'
14import * as XyzStatusphereGetUser from './types/xyz/statusphere/getUser.js'
15import * as XyzStatusphereSendStatus from './types/xyz/statusphere/sendStatus.js'
16
17export function createServer(options?: XrpcOptions): Server {
18 return new Server(options)
19}
20
21export class Server {
22 xrpc: XrpcServer
23 xyz: XyzNS
24
25 constructor(options?: XrpcOptions) {
26 this.xrpc = createXrpcServer(schemas, options)
27 this.xyz = new XyzNS(this)
28 }
29}
30
31export class XyzNS {
32 _server: Server
33 statusphere: XyzStatusphereNS
34
35 constructor(server: Server) {
36 this._server = server
37 this.statusphere = new XyzStatusphereNS(server)
38 }
39}
40
41export class XyzStatusphereNS {
42 _server: Server
43
44 constructor(server: Server) {
45 this._server = server
46 }
47
48 getStatuses<A extends Auth = void>(
49 cfg: MethodConfigOrHandler<
50 A,
51 XyzStatusphereGetStatuses.QueryParams,
52 XyzStatusphereGetStatuses.HandlerInput,
53 XyzStatusphereGetStatuses.HandlerOutput
54 >,
55 ) {
56 const nsid = 'xyz.statusphere.getStatuses' // @ts-ignore
57 return this._server.xrpc.method(nsid, cfg)
58 }
59
60 getUser<A extends Auth = void>(
61 cfg: MethodConfigOrHandler<
62 A,
63 XyzStatusphereGetUser.QueryParams,
64 XyzStatusphereGetUser.HandlerInput,
65 XyzStatusphereGetUser.HandlerOutput
66 >,
67 ) {
68 const nsid = 'xyz.statusphere.getUser' // @ts-ignore
69 return this._server.xrpc.method(nsid, cfg)
70 }
71
72 sendStatus<A extends Auth = void>(
73 cfg: MethodConfigOrHandler<
74 A,
75 XyzStatusphereSendStatus.QueryParams,
76 XyzStatusphereSendStatus.HandlerInput,
77 XyzStatusphereSendStatus.HandlerOutput
78 >,
79 ) {
80 const nsid = 'xyz.statusphere.sendStatus' // @ts-ignore
81 return this._server.xrpc.method(nsid, cfg)
82 }
83}