0.8.0 • Published 8 months ago

@atproto/xrpc-server v0.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@atproto/xrpc-server: atproto HTTP API server library

TypeScript library for implementing atproto HTTP API services, with Lexicon schema validation.

NPM Github CI Status

Usage

import { LexiconDoc } from '@atproto/lexicon'
import * as xrpc from '@atproto/xrpc-server'
import express from 'express'

const lexicons: LexiconDoc[] = [
  {
    lexicon: 1,
    id: 'io.example.ping',
    defs: {
      main: {
        type: 'query',
        parameters: {
          type: 'params',
          properties: { message: { type: 'string' } },
        },
        output: {
          encoding: 'application/json',
        },
      },
    },
  },
]

// create xrpc server
const server = xrpc.createServer(lexicons)

function ping(ctx: {
  auth: xrpc.HandlerAuth | undefined
  params: xrpc.Params
  input: xrpc.HandlerInput | undefined
  req: express.Request
  res: express.Response
}) {
  return { encoding: 'application/json', body: { message: ctx.params.message } }
}

server.method('io.example.ping', ping)

// mount in express
const app = express()
app.use(server.router)
app.listen(8080)

License

This project is dual-licensed under MIT and Apache 2.0 terms:

Downstream projects and end users may chose either license individually, or both together, at their discretion. The motivation for this dual-licensing is the additional software patent assurance provided by Apache 2.0.

0.7.11

12 months ago

0.7.10

12 months ago

0.7.9

12 months ago

0.7.13

11 months ago

0.7.12

11 months ago

0.7.6

1 year ago

0.7.5

1 year ago

0.7.8

1 year ago

0.7.7

1 year ago

0.7.19

8 months ago

0.7.18

9 months ago

0.7.15

10 months ago

0.7.14

10 months ago

0.7.17

9 months ago

0.7.16

9 months ago

0.7.2

1 year ago

0.8.0

8 months ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.3

1 year ago

0.6.4

1 year ago

0.5.4-rc.0

2 years ago

0.6.1-rc.0

1 year ago

0.6.2

1 year ago

0.5.3

2 years ago

0.6.1

1 year ago

0.5.2

2 years ago

0.6.0

1 year ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.4

2 years ago

0.4.4-next.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.3

2 years ago

0.3.0

3 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.1

3 years ago