Add file: "tslint.json".

Fix tslint errors.
This commit is contained in:
Cyril Schumacher
2017-06-11 13:49:55 +02:00
parent 94330023d9
commit d290995d52
3 changed files with 95 additions and 92 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}