corekey
v1.0.0
Published
A simply Misskey library for Node.js
Downloads
4
Readme
corekey
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.
import {
App,
AuthSession
} from 'corekey';
2. Create a Misskey App
You can create a Misskey App in App.create static method.
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!
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.
await account.request('notes/create', {
text: 'corekey test'
});
You can also upload binary data. Let's upload files to your drive!
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.
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:
const version: string = await Server.getVersion('misskey.io');
Note that you need to import Server
class from the corekey.
License
MIT