Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marihachi/corekey

(Deprecated!) A simply Misskey library for Node.js
https://github.com/marihachi/corekey

async-await misskey nodejs promise typescript

Last synced: 13 days ago
JSON representation

(Deprecated!) A simply Misskey library for Node.js

Awesome Lists containing this project

README

        

# corekey
**Deprecated!**
The official api library is now out -> [misskey.js](https://github.com/misskey-dev/misskey.js)

A simply Misskey library for Node.js

## Installation
```
npm i corekey
```

## Usage
### 1. Import the corekey library
You need to import classes you want to use.
```ts
import {
App,
AuthSession
} from 'corekey';
```

### 2. Create a Misskey App
You can create a Misskey App in App.create static method.
```ts
const app = await App.create('misskey.io', 'example app', 'generated by corekey', ['write:notes']);
```

### 3. Start a session of the app authorization
Let's get your account instance!
```ts
const session = await AuthSession.generate(app);
console.log('open in your browser: ', session.url);

const account = await session.waitForAuth();
```

### 4. Access various APIs
For example, you can post your notes to the Misskey.
```ts
await account.request('notes/create', {
text: 'corekey test'
});
```

You can also upload binary data. Let's upload files to your drive!
```ts
await account.requestBinary('drive/files/create', {
force: true,
file: fs.createReadStream('picture.jpg');
});
```

Note: If you use `await`, you need to wrap the statement with Async Function.

Enjoy!

## Other features
### Configuration of requester
The requesters provide processing of API request.
You can define and set a custom-requester to the `Configuration.Requester`.
The requester needs to implement the `IRequester` interface.
The default value of `Configuration.Requester` is `FetchRequester`.
`FetchRequester` fetches the API execution result by using the Fetch API.

e.g.
```ts
Configuration.Requester = new StubRequester();
```

### Version acquisition of Misskey instance
You may need to get the version of Misskey instance when authorization of a Misskey App.
You can get version of Misskey instance as follows:
```ts
const version: string = await Server.getVersion('misskey.io');
```
Note that you need to import `Server` class from the corekey.

## License
MIT