class LabelerServer

Constructor

constructor(options)

Create a labeler server.

Parameters

options: LabelerOptions

Configuration options.

Properties

app: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

The Fastify application instance.

db: Database

The SQLite database instance.

did: string

The DID of the labeler account.

queryLabelsHandler: QueryHandler<{ cursor?: string; limit?: string; sources?: string | string[]; ... }>

Handler for com.atproto.label.queryLabels.

subscribeLabelsHandler: SubscriptionHandler<{ cursor?: string; }>

Handler for com.atproto.label.subscribeLabels.

unknownMethodHandler: QueryHandler

Catch-all handler for unknown XRPC methods.

Methods

start(port, callback?)

Start the server.

Parameters

port: number

The port to listen on.

callback: (error: Error | null address: string) => void = ...

A callback to run when the server is started.

stop(callback?)

Stop the server.

Parameters

callback: () => void = ...

A callback to run when the server is stopped.

createLabel(label)

Create and insert a label into the database, emitting it to subscribers.

Parameters

label: CreateLabelData

The label to create.

Returns

Promise<SavedLabel>

The created label.

createLabels(subject, labels)

Create and insert labels into the database, emitting them to subscribers.

Parameters

subject: { cid?: string; uri: string; }

The subject of the labels.

labels: { create?: string[]; negate?: string[]; }

The labels to create.

Returns

Promise<SavedLabel[]>

The created labels.