FoundKey microblogging server.
Go to file
marihachi 83b86c745d
update endpoints (#15)
* update endpoints

* add endpoints
* endpoint
* endpoints

* update announcements endpoint

* replace to DateString

* update antennas endpoints

* update app endpoints

* update auth endpoints

* update entity: Antenna

* admin/delete-all-files-of-a-user

* fix

* admin/delete-logs

* update endpoints
* admin/ad/delete
* admin/announcements/delete

* update endpoints
* admin/federation/delete-all-files
* clips/delete

* update endpoints
* drive/files/delete
* drive/folders/delete
* gallery/posts/delete
* i/delete-account
* mute/delete

* update endpoints
* notes/favorites/delete
* notes/reactions/delete
* notes/watching/delete
* users/groups/delete
* users/lists/delete

* specifical id

* update antennas/notes endpoint
2021-05-21 12:27:13 +09:00
src update endpoints (#15) 2021-05-21 12:27:13 +09:00
test add test 2021-05-19 14:01:04 +09:00
test-d test 2021-05-17 23:55:13 +09:00
.editorconfig tab 2021-05-16 18:22:19 +09:00
.gitignore Add ignore config 2021-05-15 01:53:41 +09:00
i-want-you.png i want you 2021-05-14 12:00:10 +09:00
jest.config.ts wip 2021-05-14 13:49:40 +09:00
LICENSE Initial commit 2021-05-11 14:14:30 +09:00
package-lock.json nannka 2021-05-16 23:42:06 +09:00
package.json tab 2021-05-16 18:22:19 +09:00
README.md ✌️ 2021-05-18 00:07:17 +09:00
tsconfig.json nannka 2021-05-16 23:42:06 +09:00

misskey.js

Strongly-typed official Misskey SDK for browsers/Node.js.

JavaScript(TypeScript)用の公式MisskeySDKです。ブラウザ/Node.js上で動作します。

以下が提供されています:

  • ユーザー認証
  • APIリクエスト
  • ストリーミング
  • ユーティリティ関数
  • Misskeyの各種モデル(ノート、ユーザー等)の型定義

Install

coming soon

Usage

Authenticate

todo

API request

都度インスタンスやトークンを指定する場合

import * as Misskey from 'misskey-js';

const meta = await Misskey.api.request('https://misskey.test', 'meta', { detail: true }, 'TOKEN');

最初にインスタンスやトークンを指定し、以後のリクエストでその情報を使いまわす場合

import * as Misskey from 'misskey-js';

const cli = new Misskey.api.APIClient({
	origin: 'https://misskey.test'
});
cli.i = { token: 'TOKEN' };

const meta = await cli.request('meta', { detail: true });

Streaming

import * as Misskey from 'misskey-js';

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const mainChannel = stream.useSharedConnection('main');
mainChannel.on('notification', notification => {
	console.log('notification received', notification);
});

チャンネルへの接続(使いまわす場合)

使いまわし可能なチャンネル(=パラメータを持たないチャンネル)に接続するときは、useSharedConnectionメソッドを使用します。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const mainChannel = stream.useSharedConnection('main');

このメソッドを用いてチャンネルに接続することで、(同じStreamインスタンスを共有している場合)プログラム上の複数個所から呼び出しても内部的にまとめられます。

チャンネルへの接続(使いまわし不可の場合)

パラメータを持つチャンネルへの接続はconnectToChannelメソッドを使用します。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const messagingChannel = stream.connectToChannel('messaging', {
	otherparty: 'xxxxxxxxxx',
});

チャンネルから切断

disposeメソッドを呼び出します。

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });

const mainChannel = stream.useSharedConnection('main');

mainChannel.dispose();

メッセージの受信

チャンネル接続インスタンスはEventEmitterを継承しており、メッセージがサーバーから受信されると受け取ったイベント名でペイロードをemitします。

import * as Misskey from 'misskey-js';

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const mainChannel = stream.useSharedConnection('main');
mainChannel.on('notification', notification => {
	console.log('notification received', notification);
});

メッセージの送信

チャンネル接続インスタンスのsendメソッドを使用してメッセージをサーバーに送信することができます。

import * as Misskey from 'misskey-js';

const stream = new Misskey.Stream('https://misskey.test', { token: 'TOKEN' });
const messagingChannel = stream.connectToChannel('messaging', {
	otherparty: 'xxxxxxxxxx',
});

messagingChannel.send('read', {
	id: 'xxxxxxxxxx'
});

Reference

useSharedConnection(channel: string): SharedConnection

使いまわし可能なチャンネル(=パラメータを持たないチャンネル)に接続します。 このメソッドを用いて接続したチャンネル接続は内部的に使いまわされるため、プログラム上の複数の場所から呼び出してもコネクションを無駄に増やさずに済みます。

connectToChannel(channel: string, params?: any): NonSharedConnection

チャンネルに接続します。返り値はそのチャンネルへのコネクションインスタンスです。