Skip to main content
Module

x/feoblog_client/mod.ts>Client

a JavaScript client for feoblog written for Deno
Latest
class Client
import { Client } from "https://deno.land/x/feoblog_client@v0.7.0/mod.ts";

A client to GET/PUT FeoBlog Items.

https://github.com/nfnitloop/feoblog https://github.com/NfNitLoop/feoblog/blob/develop/docs/data_format.md

This client is available publicly as part of https://deno.land/x/feoblog_client. That is a (mostly) copy of the Client class from https://github.com/NfNitLoop/feoblog/blob/develop/web-client/ts/client.ts

A client takes a base_url parameter and knows how to construct REST URLs based off of that. To communicate among 2+ servers, instantiate a client for each server.

Constructors

new
Client(config: Config)

Properties

private
base_url: string
readonly
url

Methods

private
attachmentURL(
userID: UserID,
signature: Signature,
fileName: string,
)
private
getItemList(itemsPath: string, params?: ItemOffsetParams): Promise<ItemList>
private
streamItemList(url: string, params?: ItemOffsetParams): AsyncGenerator<ItemListEntry>
getAttachment(
userID: UserID,
signature: Signature,
fileName: string,
): Promise<ArrayBuffer | null>

Download an attachment from a server, if it exists.

Warning: stores the attachment in memory.

getAttachmentMeta(
userID: UserID,
signature: Signature,
fileName: string,
): Promise<AttachmentMeta>

Get metadata a server has about an attachment.

An async stream over items on the site's home page.

getItem(
userID: UserID | string,
signature: Signature | string,
options?: GetItemOptions,
): Promise<Item | null>

Load an Item from the server, if it exists.

By default, validates the signature of the Item before returning it.

getItemBytes(
userID: UserID | string,
signature: Signature | string,
options?: GetItemOptions,
): Promise<Uint8Array | null>

Like getItem, but returns the item bytes so that the signature remains valid over the (serialized) bytes.

getProfile(userID: UserID | string): Promise<ProfileResult | null>

Like getItem, but just gets the latest profile that a server knows about for a given user ID. The signature is returned in a header from the server. This function verifies that signature before returning the Item. We also verify that the Item has a Profile.

getReplyItems(userID: UserID, signature: Signature): AsyncGenerator<ItemListEntry>

An async stream of all known replies to an item.

getUserFeedItems(userID: UserID, params?: ItemOffsetParams): AsyncGenerator<ItemListEntry>

An async stream over a user's feed. (i.e.: content of those they follow, and themself)

getUserItems(userID: UserID, params?: ItemOffsetParams): AsyncGenerator<ItemListEntry>

An async stream over a users's Items.

putAttachment(
userID: UserID,
signature: Signature,
fileName: string,
blob: Blob,
): Promise<void>

After you putItem() an item that has Attachments, the server may allow you to upload the attachments (if they do not violate your quota)

putItem(
userID: UserID,
signature: Signature,
bytes: Uint8Array,
): Promise<Response>

Write an item to the server. This assumes you have provided a valid userID & signature for the given bytes. (The receiving server will check it, though!)