mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-24 22:53:09 +02:00
やった
This commit is contained in:
parent
767df5967a
commit
6c938905f9
2 changed files with 34 additions and 9 deletions
19
README.md
19
README.md
|
@ -5,7 +5,24 @@ coming soon
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
## API request
|
## API request
|
||||||
todo
|
都度インスタンスやトークンを指定する場合
|
||||||
|
``` ts
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
|
||||||
|
const meta = await Misskey.api.request('https://misskey.test', 'meta', { detail: true }, 'TOKEN');
|
||||||
|
```
|
||||||
|
|
||||||
|
最初にインスタンスやトークンを指定し、以後のリクエストでその情報を使いまわす場合
|
||||||
|
``` ts
|
||||||
|
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
|
## Streaming
|
||||||
todo
|
todo
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
/**
|
|
||||||
* Unit testing TypeScript types.
|
|
||||||
* with https://github.com/SamVerschueren/tsd
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { expectType } from 'tsd';
|
import { expectType } from 'tsd';
|
||||||
import * as Misskey from '../src';
|
import * as Misskey from '../src';
|
||||||
|
|
||||||
describe('API', () => {
|
describe('API', () => {
|
||||||
test('returns node that has sprcified type', async () => {
|
describe('request', () => {
|
||||||
const res = await Misskey.api.request('https://misskey.test', 'meta', { detail: true }, 'TOKEN');
|
test('success', async () => {
|
||||||
expectType<Misskey.entities.InstanceMetadata>(res);
|
const res = await Misskey.api.request('https://misskey.test', 'meta', { detail: true }, 'TOKEN');
|
||||||
|
expectType<Misskey.entities.InstanceMetadata>(res);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('APIClient', () => {
|
||||||
|
test('success', async () => {
|
||||||
|
const cli = new Misskey.api.APIClient({
|
||||||
|
origin: 'https://misskey.test'
|
||||||
|
});
|
||||||
|
cli.i = { token: 'TOKEN' };
|
||||||
|
const res = await cli.request('meta', { detail: true });
|
||||||
|
expectType<Misskey.entities.InstanceMetadata>(res);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue