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: Client

The SQLite database instance.

did: `did:${string}`

The DID of the labeler account.

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

Handler for com.atproto.label.subscribeLabels.

healthHandler: QueryHandler

Handler for the health check endpoint.

unknownMethodHandler: QueryHandler

Catch-all handler for unknown XRPC methods.

errorHandler: (error: FastifyError request: FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>> reply: FastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>) => void

Default error handler.

Methods

__type(error, request, reply)

Parameters

error: FastifyError
request: FastifyRequest<RouteGenericInterface, RawServerDefault, IncomingMessage, FastifySchema, FastifyTypeProviderDefault, unknown, FastifyBaseLogger, ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>>
reply: FastifyReply<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>
Overload 1/2

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.

start(options, callback)

Start the server.

Parameters

options: FastifyListenOptions

Options for the server.

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

A callback to run when the server is started.

close(callback?)

Stop the server.

Parameters

callback: () => void = ...

A callback to run when the server is stopped.

stop(callback?)

Alias for LabelerServer#close.

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.