mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #14022 from cyrilschumacher/master
Add definitions for shipit, shipit-utils and express-rate-limit.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import RateLimit = require("express-rate-limit");
|
||||
|
||||
var apiLimiter = new RateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 100,
|
||||
delayMs: 0 // disabled
|
||||
});
|
||||
|
||||
var createAccountLimiter = new RateLimit({
|
||||
windowMs: 60 * 60 * 1000, // 1 hour window
|
||||
delayAfter: 1, // begin slowing down responses after the first request
|
||||
delayMs: 3 * 1000, // slow down subsequent responses by 3 seconds per request
|
||||
max: 5, // start blocking after 5 requests
|
||||
message: "Too many accounts created from this IP, please try again after an hour"
|
||||
});
|
||||
|
||||
class SomeStore implements RateLimit.Store {
|
||||
incr(key: string, cb: RateLimit.StoreIncrementCallback) { }
|
||||
resetAll() { }
|
||||
resetKey(key: string) { };
|
||||
};
|
||||
|
||||
var limiterWithStore = new RateLimit({
|
||||
store: new SomeStore()
|
||||
});
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions for express-rate-limit 2.6
|
||||
// Project: https://github.com/nfriedly/express-rate-limit
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import express = require("express");
|
||||
|
||||
declare namespace RateLimit {
|
||||
type StoreIncrementCallback = (err?: {}, hits?: number) => void;
|
||||
|
||||
export interface Store {
|
||||
incr: (key: string, cb: StoreIncrementCallback) => void;
|
||||
resetAll: () => void;
|
||||
resetKey: (key: string) => void;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
delayAfter?: number;
|
||||
delayMs?: number;
|
||||
handlers?: () => any;
|
||||
headers?: boolean;
|
||||
keyGenerator?: () => string;
|
||||
max?: number;
|
||||
message?: string;
|
||||
skip?: () => boolean;
|
||||
statusCode?: number;
|
||||
store?: Store;
|
||||
windowMs?: number;
|
||||
}
|
||||
}
|
||||
|
||||
interface RateLimitStatic {
|
||||
new(options: RateLimit.Options): express.RequestHandler;
|
||||
}
|
||||
|
||||
declare var RateLimit: RateLimitStatic;
|
||||
export = RateLimit;
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"express-rate-limit-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for shipit-utils 1.4
|
||||
// Project: https://github.com/shipitjs/shipit-utils
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import shipit = require("shipit");
|
||||
|
||||
type GruntOrShipit = typeof shipit | {};
|
||||
type EmptyCallback = () => void;
|
||||
|
||||
export function equalValues(value: any[]): void;
|
||||
export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit;
|
||||
export function getShipit(gruntOrShipit: GruntOrShipit): typeof shipit;
|
||||
export function registerTask(gruntOrShipit: GruntOrShipit, name: string, dependenciesOrTask: string[] | EmptyCallback): typeof shipit;
|
||||
export function runTask(gruntOrShipit: {}): void;
|
||||
@@ -0,0 +1,11 @@
|
||||
import shipit = require("shipit");
|
||||
import utils = require("shipit-utils");
|
||||
|
||||
var originalShipit = utils.getShipit(shipit);
|
||||
|
||||
var task = () => {
|
||||
return shipit.local("sleep 10s");
|
||||
};
|
||||
|
||||
utils.registerTask(originalShipit, "myTask", task);
|
||||
utils.registerTask(originalShipit, "myTask", ["some", "other", "tasks"]);
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"shipit-utils-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// Type definitions for shipit-cli 1.5
|
||||
// Project: https://github.com/shipitjs/shipit
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as child_process from "child_process";
|
||||
|
||||
declare namespace shipit {
|
||||
type LocalOrRemoteCommand = (command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void) => PromiseLike<ShipitLocal>;
|
||||
type EmptyCallback = () => void;
|
||||
type TaskExecution = (name: string, depsOrFn: string[] | EmptyCallback, fn: () => void) => any;
|
||||
|
||||
interface Options {
|
||||
environment: string;
|
||||
stderr: fs.WriteStream;
|
||||
stdout: fs.WriteStream;
|
||||
}
|
||||
|
||||
interface ShipitLocal {
|
||||
child: child_process.ChildProcess;
|
||||
stderr: fs.WriteStream;
|
||||
stdout: fs.WriteStream;
|
||||
}
|
||||
|
||||
interface Tasks {
|
||||
[name: string]: Task;
|
||||
}
|
||||
|
||||
interface Task {
|
||||
blocking: boolean;
|
||||
dep: string[];
|
||||
fn: () => void;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function blTask(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): any;
|
||||
export function emit(name: string): any;
|
||||
export function initConfig(config: {}): typeof shipit;
|
||||
export function local(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike<ShipitLocal>;
|
||||
export function log(log: any): void;
|
||||
export function log(...log: any[]): void;
|
||||
export function on(name: string, callback: (e: any) => void): any;
|
||||
export function remote(command: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike<ShipitLocal>;
|
||||
export function remoteCopy(src: string, dest: string, options?: child_process.ExecOptions, callback?: (error: Error, stdout: string, stderr: string) => void): PromiseLike<ShipitLocal>;
|
||||
export function start(tasks: string | string[]): typeof shipit;
|
||||
export function start(...tasks: string[]): typeof shipit;
|
||||
export function task(name: string, depsOrFn: string[] | EmptyCallback, fn?: () => void): typeof shipit;
|
||||
|
||||
export var config: {};
|
||||
export var domain: any;
|
||||
export var doneCallback: any;
|
||||
export var environment: string;
|
||||
export var seq: any[];
|
||||
export var tasks: Tasks;
|
||||
export var isRunning: boolean;
|
||||
}
|
||||
|
||||
//tslint:disable-next-line:export-just-namespace
|
||||
export = shipit;
|
||||
export as namespace shipit;
|
||||
@@ -0,0 +1,50 @@
|
||||
import shipit = require("shipit");
|
||||
|
||||
shipit.initConfig({
|
||||
default: {
|
||||
workspace: "/tmp/github-monitor",
|
||||
deployTo: "/tmp/deploy_to",
|
||||
repositoryUrl: "https://github.com/user/repo.git",
|
||||
ignores: [".git", "node_modules"],
|
||||
rsync: ["--del"],
|
||||
keepReleases: 2,
|
||||
key: "/path/to/key",
|
||||
shallowClone: true
|
||||
},
|
||||
staging: {
|
||||
servers: "user@myserver.com"
|
||||
}
|
||||
});
|
||||
|
||||
shipit.task("build", () => {
|
||||
shipit.emit("built");
|
||||
});
|
||||
|
||||
shipit.on("built", () => {
|
||||
shipit.start("start-server");
|
||||
});
|
||||
|
||||
shipit.task("pwd", () => {
|
||||
return shipit.remote("pwd");
|
||||
});
|
||||
|
||||
shipit.blTask("pwd", () => {
|
||||
return shipit.remote("pwd");
|
||||
});
|
||||
|
||||
shipit.start("task");
|
||||
shipit.start("task1", "task2");
|
||||
shipit.start(["task1", "task2"]);
|
||||
|
||||
shipit.local("ls -lah", {cwd: "/tmp/deploy/workspace"}).then((res: any) => {
|
||||
console.log(res.stdout);
|
||||
console.log(res.stderr);
|
||||
});
|
||||
|
||||
shipit.remote("ls -lah").then((res: any) => {
|
||||
console.log(res[0].stdout);
|
||||
console.log(res[0].stderr);
|
||||
});
|
||||
|
||||
shipit.remoteCopy("/tmp/workspace", "/opt/web/myapp").then(() => {});
|
||||
shipit.log("hello %s", "world");
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"shipit-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user