Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

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

docs: xrpc with lex sdk

+17 -29
+17 -29
xrpc/mod.ts
··· 6 6 * 7 7 * @example Fetching an XRPC endpoint 8 8 * ```typescript 9 - * import { LexiconDoc } from '@atp/lexicon' 9 + * import { l } from '@atp/lex' 10 10 * import { Client } from '@atp/xrpc' 11 11 * 12 - * const pingLexicon = { 13 - * lexicon: 1, 14 - * id: 'io.example.ping', 15 - * defs: { 16 - * main: { 17 - * type: 'query', 18 - * description: 'Ping the server', 19 - * parameters: { 20 - * type: 'params', 21 - * properties: { message: { type: 'string' } }, 22 - * }, 23 - * output: { 24 - * encoding: 'application/json', 25 - * schema: { 26 - * type: 'object', 27 - * required: ['message'], 28 - * properties: { message: { type: 'string' } }, 29 - * }, 30 - * }, 31 - * }, 32 - * }, 33 - * } satisfies LexiconDoc 12 + * const ping = l.query( 13 + * 'io.example.ping', 14 + * l.params({ 15 + * message: l.string(), 16 + * }), 17 + * l.jsonPayload({ 18 + * message: l.string(), 19 + * }), 20 + * ) 34 21 * 35 - * const client = new Client('https://ping.example.com', [ 36 - * pingLexicon, 37 - * ]) 22 + * const client = new Client('https://ping.example.com') 38 23 * 39 - * const res1 = await client.xrpc('io.example.ping', { 40 - * message: 'hello world', 24 + * const res = await client.xrpc(ping, { 25 + * params: { 26 + * message: 'hello world', 27 + * }, 41 28 * }) 42 - * res1.body // => {message: 'hello world'} 29 + * 30 + * res.data // => { message: 'hello world' } 43 31 * ``` 44 32 * @module 45 33 */