Compare commits
14 Commits
47ead2151c
...
1.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 845dad288e | |||
| 84e10c529b | |||
| 85c8f8cc9f | |||
| 99387d1b3b | |||
| 8b2b1d2b13 | |||
| 59bfd58fba | |||
| 8c4dfeaa77 | |||
| e4338c80e7 | |||
| 004bfde9af | |||
| 895b693f81 | |||
| 336db2a5ca | |||
| f57ca58935 | |||
| f2c2007e07 | |||
| 714a3b852c |
@@ -1,48 +1,62 @@
|
|||||||
# Better uwuzu SDK
|
# Better uwuzu SDK
|
||||||
[uwuzu.js](https://github.com/PutonFPS/uwuzu.js)みたいなやつです。uwuzuのAPIがいじれます。
|
[uwuzu.js](https://github.com/PutonFPS/uwuzu.js)みたいなやつです。uwuzuのAPIがいじれます。
|
||||||
|
|
||||||
# 使い方
|
# 使い方
|
||||||
## インストール
|
## インストール
|
||||||
初期リリース出たら書きます
|
```bash
|
||||||
|
# npm
|
||||||
## 初期化
|
npm install git+https://gitea.last2014.com/last2014/better-uwuzu-sdk.git#1.0.3
|
||||||
```ts
|
|
||||||
import uwuzu from "better-uwuzu-sdk";
|
# yarn
|
||||||
import type ApiMap from "better-uwuzu-sdk/1.6.11/map";
|
yarn add git+https://gitea.last2014.com/last2014/better-uwuzu-sdk.git#1.0.3
|
||||||
|
|
||||||
const client = new uwuzu<ApiMap>({
|
# pnpm
|
||||||
origin: "https://uwuzu.net",
|
pnpm add git+https://gitea.last2014.com/last2014/better-uwuzu-sdk.git#1.0.3
|
||||||
});
|
```
|
||||||
|
> **NOTE**
|
||||||
try {
|
> このSDKはnpmリポジトリがありません。Gitリポジトリを使用しています。
|
||||||
client.token = "APITOKEN";
|
|
||||||
} catch (err) {
|
> **WARNING**
|
||||||
console.error(err);
|
> `#main`でのインストールもできますが破壊的変更の際に面倒だと思います。サポートしません。
|
||||||
}
|
|
||||||
```
|
## 初期化
|
||||||
型とJSDoc見ればわかります。トークンはなくても`serverinfo-api`や`token/get`は動きますが大体の事例では入れると思います。`uwuzu().token`の`set`は検証を行うわけではありませんが64文字でない、空文字列であるなどの場合はエラーが発生します。
|
```ts
|
||||||
|
import uwuzu from "better-uwuzu-sdk";
|
||||||
## APIリクエスト
|
import type ApiMap from "better-uwuzu-sdk/1.6.11/map";
|
||||||
```ts
|
|
||||||
import uwuzu from "better-uwuzu-sdk";
|
const client = new uwuzu<ApiMap>({
|
||||||
import type ApiMap from "better-uwuzu-sdk/1.6.11/map";
|
origin: "https://uwuzu.net",
|
||||||
|
});
|
||||||
const client = new uwuzu<ApiMap>({
|
|
||||||
origin: "https://uwuzu.net",
|
try {
|
||||||
});
|
client.token = "APITOKEN";
|
||||||
|
} catch (err) {
|
||||||
try {
|
console.error(err);
|
||||||
client.token = "APITOKEN";
|
}
|
||||||
|
```
|
||||||
const me = await client.request("me/");
|
型とJSDoc見ればわかります。トークンはなくても`serverinfo-api`や`token/get`は動きますが大体の事例では入れると思います。`uwuzu().token`の`set`は検証を行うわけではありませんが64文字でない、空文字列であるなどの場合はエラーが発生します。
|
||||||
|
|
||||||
if (me.error_code) {
|
## APIリクエスト
|
||||||
throw new Error(me.error_code);
|
```ts
|
||||||
}
|
import uwuzu from "better-uwuzu-sdk";
|
||||||
|
import type ApiMap from "better-uwuzu-sdk/1.6.11/map";
|
||||||
console.log(`あなたは${me.username}です。`);
|
|
||||||
} catch (err) {
|
const client = new uwuzu<ApiMap>({
|
||||||
console.error(err);
|
origin: "https://uwuzu.net",
|
||||||
}
|
});
|
||||||
```
|
|
||||||
|
try {
|
||||||
|
client.token = "APITOKEN";
|
||||||
|
|
||||||
|
const me = await client.request("me/");
|
||||||
|
|
||||||
|
if (me.error_code) {
|
||||||
|
throw new Error(me.error_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`あなたは${me.username}です。`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
```
|
||||||
普通のSDKです。`uwuzu().request()`の第一引数はエンドポイント、第二引数はbodyです。bodyにトークンは自動入力されるので上記の例のように省略できます。
|
普通のSDKです。`uwuzu().request()`の第一引数はエンドポイント、第二引数はbodyです。bodyにトークンは自動入力されるので上記の例のように省略できます。
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "better-uwuzu-sdk",
|
"name": "better-uwuzu-sdk",
|
||||||
"version": "1.0.0",
|
"version": "1.0.3",
|
||||||
"description": "A better uwuzu SDK.",
|
"description": "A better uwuzu SDK.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/types/index.d.ts",
|
"types": "dist/types/index.d.ts",
|
||||||
|
|||||||
Vendored
+29
-1
@@ -6,6 +6,20 @@ import MeNotification from "./me/notification";
|
|||||||
import MeNotificationRead from "./me/notification/read";
|
import MeNotificationRead from "./me/notification/read";
|
||||||
import MeSettings from "./me/settings";
|
import MeSettings from "./me/settings";
|
||||||
import Ueuse from "./ueuse";
|
import Ueuse from "./ueuse";
|
||||||
|
import UeuseGet from "./ueuse/get";
|
||||||
|
import UeuseReplies from "./ueuse/replies";
|
||||||
|
import UeuseMentions from "./ueuse/mentions";
|
||||||
|
import UeuseSearch from "./ueuse/search";
|
||||||
|
import UeuseCreate from "./ueuse/create";
|
||||||
|
import UeuseDelete from "./ueuse/delete";
|
||||||
|
import UeuseBookmark from "./ueuse/bookmark";
|
||||||
|
import FavoriteChange from "./favorite/change";
|
||||||
|
import FavoriteGet from "./favorite/get";
|
||||||
|
import TokenGet from "./token/get";
|
||||||
|
import AdminUsers from "./admin/users";
|
||||||
|
import AdminUsersSanction from "./admin/users/sanction";
|
||||||
|
import AdminReports from "./admin/reports";
|
||||||
|
import AdminReportsResolve from "./admin/reports/resolve";
|
||||||
|
|
||||||
export type ApiMap =
|
export type ApiMap =
|
||||||
& ServerInfo
|
& ServerInfo
|
||||||
@@ -15,4 +29,18 @@ export type ApiMap =
|
|||||||
& MeSettings
|
& MeSettings
|
||||||
& Users
|
& Users
|
||||||
& UsersFollow
|
& UsersFollow
|
||||||
& Ueuse;
|
& Ueuse
|
||||||
|
& UeuseGet
|
||||||
|
& UeuseReplies
|
||||||
|
& UeuseMentions
|
||||||
|
& UeuseSearch
|
||||||
|
& UeuseCreate
|
||||||
|
& UeuseDelete<string>
|
||||||
|
& UeuseBookmark
|
||||||
|
& FavoriteChange
|
||||||
|
& FavoriteGet
|
||||||
|
& TokenGet
|
||||||
|
& AdminUsers
|
||||||
|
& AdminUsersSanction<string>
|
||||||
|
& AdminReports
|
||||||
|
& AdminReportsResolve;
|
||||||
@@ -88,9 +88,6 @@ export default class uwuzu<
|
|||||||
endpoint as string,
|
endpoint as string,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
cache: "no-store",
|
cache: "no-store",
|
||||||
body: bodyParsed,
|
body: bodyParsed,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user