@wishcore/wish-sdk
Version:
Wish API for node. Used for building Wish Apps.
51 lines (50 loc) • 1.1 kB
TypeScript
import { Peer } from './peer';
import { App } from './sdk';
import { Client, Server } from '@wishcore/wish-rpc';
export interface Protocol {
online?: (peer: Peer, client: Client) => void;
offline?: (peer: Peer) => void;
/**
* Optional handler
*
* Add using:
*
* ```typescript
* app.server.insertMethods({
* _get: {},
* get: async (req, res, context) {
* res.send('response');
* }
* })
* ```
*/
handler?: {
[handler: string]: any;
};
}
export interface ProtocolMap {
[protocol: string]: {
online: (peer: Peer, client: Client) => void;
offline: (peer: Peer) => void;
server: Server;
};
}
export declare class RpcApp {
private opts;
clients: {
[peer: string]: Client;
};
protocols: ProtocolMap;
connections: {
[key: string]: number;
};
wish: App;
server: Server;
constructor(opts: {
name: string;
corePort?: number;
protocols: {
[protocol: string]: Protocol;
};
});
}