mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Add file: "tslint.json".
Fix tslint errors.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import * as bunnymq from "bunnymq";
|
||||
|
||||
// Basic usage
|
||||
var instance = bunnymq({ host: "amqp://localhost" });
|
||||
const instance = bunnymq({ host: "amqp://localhost" });
|
||||
|
||||
// Publisher
|
||||
instance.publish("queue:name", "message");
|
||||
@@ -16,7 +16,7 @@ instance.publish("queue:name", { message: "content" }, { routingKey: "my-routing
|
||||
instance.producer.produce("queue:name", { message: "content" }, { rpc: true, routingKey: "my-routing-key", timeout: 1000 });
|
||||
|
||||
// Config
|
||||
var custom = bunnymq({
|
||||
const instanceWithCustomOptions = bunnymq({
|
||||
host: "amqp://localhost",
|
||||
prefetch: 5,
|
||||
requeue: true,
|
||||
|
||||
180
types/bunnymq/index.d.ts
vendored
180
types/bunnymq/index.d.ts
vendored
@@ -1,98 +1,98 @@
|
||||
// Type definitions for node-bunnymq 2.3.2
|
||||
// Type definitions for node-bunnymq 2.3
|
||||
// Project: https://github.com/dial-once/node-bunnymq
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "bunnymq" {
|
||||
namespace bunnymq {
|
||||
export type ConsumerCallback<T> = (...args: any[]) => T;
|
||||
export type LoggerOutput = (format: any, ...args: any[]) => void;
|
||||
declare function bunnymq(options?: bunnymq.Options): bunnymq.Instance;
|
||||
declare namespace bunnymq {
|
||||
type ConsumerCallback<T> = (...args: any[]) => T;
|
||||
type LoggerOutput = (format: any, ...args: any[]) => void;
|
||||
|
||||
export interface Connection {
|
||||
[address: string]: any;
|
||||
startedAt: string;
|
||||
}
|
||||
export interface Consumer {
|
||||
/**
|
||||
* Handle messages from a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {ConsumerCallback} callback A callback.
|
||||
*/
|
||||
consume<T>(queue: string, callback: ConsumerCallback<T>): void;
|
||||
}
|
||||
|
||||
export interface Instance {
|
||||
connection: Connection;
|
||||
consumer: Consumer;
|
||||
producer: Producer;
|
||||
|
||||
/**
|
||||
* Subscriber to handle messages from a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {ConsumerCallback} callback A callback.
|
||||
*/
|
||||
subscribe<T>(queueName: string, callback: ConsumerCallback<T>): void;
|
||||
|
||||
/**
|
||||
* Publisher to send messages to a named queue.
|
||||
*
|
||||
* @type {Producer}
|
||||
* @return {Promise} The consumer response.
|
||||
*/
|
||||
publish<T>(queueName: string, message: any, options?: ProducerOptions): Promise<T>;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
debug: LoggerOutput;
|
||||
error: LoggerOutput;
|
||||
info: LoggerOutput;
|
||||
log: LoggerOutput;
|
||||
warn: LoggerOutput;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
consumerSuffix?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
|
||||
/**
|
||||
* Number of fetched messages at once on the channel.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
prefetch?: number;
|
||||
|
||||
/**
|
||||
* Requeue put back message into the broker if consumer crashes/trigger exception.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
requeue?: boolean;
|
||||
rpcTimeout?: number;
|
||||
timeout?: number;
|
||||
transport?: any;
|
||||
}
|
||||
|
||||
export interface Producer {
|
||||
/**
|
||||
* Send messages to a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {any} message A message.
|
||||
* @return {Promise} The consumer response.
|
||||
*/
|
||||
produce<T>(queue: string, message: any, options?: ProducerOptions): Promise<T>;
|
||||
}
|
||||
|
||||
export interface ProducerOptions {
|
||||
routingKey?: string;
|
||||
rpc?: boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
interface Connection {
|
||||
[address: string]: any;
|
||||
startedAt: string;
|
||||
}
|
||||
|
||||
function bunnymq(options?: bunnymq.Options): bunnymq.Instance;
|
||||
export = bunnymq;
|
||||
interface Consumer {
|
||||
/**
|
||||
* Handle messages from a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {ConsumerCallback} callback A callback.
|
||||
*/
|
||||
consume<T>(queue: string, callback: ConsumerCallback<T>): void;
|
||||
}
|
||||
|
||||
interface Instance {
|
||||
connection: Connection;
|
||||
consumer: Consumer;
|
||||
producer: Producer;
|
||||
|
||||
/**
|
||||
* Subscriber to handle messages from a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {ConsumerCallback} callback A callback.
|
||||
*/
|
||||
subscribe<T>(queueName: string, callback: ConsumerCallback<T>): void;
|
||||
|
||||
/**
|
||||
* Publisher to send messages to a named queue.
|
||||
*
|
||||
* @type {Producer}
|
||||
* @return {Promise} The consumer response.
|
||||
*/
|
||||
publish<T>(queueName: string, message: any, options?: ProducerOptions): Promise<T>;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
debug: LoggerOutput;
|
||||
error: LoggerOutput;
|
||||
info: LoggerOutput;
|
||||
log: LoggerOutput;
|
||||
warn: LoggerOutput;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
consumerSuffix?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
|
||||
/**
|
||||
* Number of fetched messages at once on the channel.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
prefetch?: number;
|
||||
|
||||
/**
|
||||
* Requeue put back message into the broker if consumer crashes/trigger exception.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
requeue?: boolean;
|
||||
rpcTimeout?: number;
|
||||
timeout?: number;
|
||||
transport?: any;
|
||||
}
|
||||
|
||||
interface Producer {
|
||||
/**
|
||||
* Send messages to a named queue.
|
||||
*
|
||||
* @param {string} queue A named queue.
|
||||
* @param {any} message A message.
|
||||
* @return {Promise} The consumer response.
|
||||
*/
|
||||
produce<T>(queue: string, message: any, options?: ProducerOptions): Promise<T>;
|
||||
}
|
||||
|
||||
interface ProducerOptions {
|
||||
routingKey?: string;
|
||||
rpc?: boolean;
|
||||
timeout?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export = bunnymq;
|
||||
export as namespace bunnymq;
|
||||
|
||||
3
types/bunnymq/tslint.json
Normal file
3
types/bunnymq/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user