export module webapis { /** * Base object going in one direction. */ export interface Call { } /** * Base incoming message from clients. */ export interface BaseIncoming extends Call { } /** * Authenticated message containing a secret we need to perform * certain operations. */ export interface AuthenticatedIncoming { secret: string; } /** * Base outgoing server response. */ export interface BaseOutgoing extends Call { _status?: string; _reason?: string; _raw?: string; } /** * Base OK message. * @type {BaseOutgoing} */ export const OK: BaseOutgoing = { _status: "ok" }; /** * Customizable FAIL message. * @method FAIL * @param {string} reason [description] * @param {string} message [description] * @return {BaseOutgoing} [description] */ export function FAIL(reason: string, message: string): BaseOutgoing { return { _status: "fail", _reason: reason, _raw: message }; } /** * Basic API error that can be thrown. * @method constructor * @param {string} public_reason [description] * @param {string} public_message [description] * @return {[type]} [description] */ export class APIError extends Error { constructor(reason: string, public message: string) { super(message); this.name = reason; this.message = message; } } }