mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-07 23:37:35 +08:00
Added typings for sticky-cluster
This commit is contained in:
25
types/sticky-cluster/index.d.ts
vendored
Normal file
25
types/sticky-cluster/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for sticky-cluster 0.3
|
||||
// Project: https://github.com/uqee/sticky-cluster
|
||||
// Definitions by: Austin Turner <https://github.com/paustint>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node"/>
|
||||
import * as http from 'http';
|
||||
|
||||
declare namespace stickyCluster {
|
||||
type InitializeFn = (callback: Callback) => void;
|
||||
type Callback = (server: http.Server) => void;
|
||||
interface Options {
|
||||
concurrency?: number;
|
||||
port?: number;
|
||||
debug?: boolean;
|
||||
prefix?: string;
|
||||
env?: (index: number) => { stickycluster_worker_index: number };
|
||||
hardShutdownDelay?: number;
|
||||
errorHandler?: (err: any) => void;
|
||||
}
|
||||
}
|
||||
|
||||
declare function stickyCluster(callback: stickyCluster.InitializeFn, options?: stickyCluster.Options): void;
|
||||
export = stickyCluster;
|
||||
34
types/sticky-cluster/sticky-cluster-tests.ts
Normal file
34
types/sticky-cluster/sticky-cluster-tests.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import stickyCluster = require('sticky-cluster');
|
||||
import * as express from 'express';
|
||||
import * as http from 'http';
|
||||
|
||||
/** test with all params */
|
||||
stickyCluster(
|
||||
(callback) => {
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
|
||||
// don't do server.listen(), just pass the server instance into the callback
|
||||
callback(server);
|
||||
},
|
||||
{
|
||||
prefix: 'sticky-cluster:',
|
||||
concurrency: 10,
|
||||
port: 3000,
|
||||
debug: true,
|
||||
hardShutdownDelay: 60 * 1000,
|
||||
env: (index) => ({ stickycluster_worker_index: index }),
|
||||
errorHandler: (err) => { console.log(err); process.exit(1); }
|
||||
}
|
||||
);
|
||||
|
||||
/** test with no params */
|
||||
stickyCluster(
|
||||
(callback) => {
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
|
||||
// don't do server.listen(), just pass the server instance into the callback
|
||||
callback(server);
|
||||
}
|
||||
);
|
||||
23
types/sticky-cluster/tsconfig.json
Normal file
23
types/sticky-cluster/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sticky-cluster-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/sticky-cluster/tslint.json
Normal file
1
types/sticky-cluster/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user