From eb6688ffef49b8d33b93ff5d44c4a96136eb5e84 Mon Sep 17 00:00:00 2001 From: javiercbk Date: Sun, 27 Nov 2016 23:09:08 -0300 Subject: [PATCH] fixed middleware types for @types/acl version update --- acl/acl-tests.ts | 17 +++++++++++++++++ acl/index.d.ts | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/acl/acl-tests.ts b/acl/acl-tests.ts index 07dc401891..c29574326d 100644 --- a/acl/acl-tests.ts +++ b/acl/acl-tests.ts @@ -12,6 +12,23 @@ var report = (err: Error, value: T) => { // Using the memory backend var acl = new Acl(new Acl.memoryBackend()); +// middleware with no optional parameters +acl.middleware(); + +acl.middleware(1); + +acl.middleware(1, () => { + return "joed"; +}); + +acl.middleware(1, () => { + return 2; +}); + +acl.middleware(1, 'joed'); + +acl.middleware(3, 'joed', 'post'); + // guest is allowed to view blogs acl.allow('guest', 'blogs', 'view'); diff --git a/acl/index.d.ts b/acl/index.d.ts index c95eafb06f..069631d2e0 100644 --- a/acl/index.d.ts +++ b/acl/index.d.ts @@ -1,13 +1,15 @@ -// Type definitions for node_acl 0.4.7 +// Type definitions for node_acl 0.4.8 // Project: https://github.com/optimalbits/node_acl // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// /// +/// import http = require('http'); import Promise = require("bluebird"); +import express = require("express"); type strings = string|string[]; type Value = string|number; @@ -49,7 +51,7 @@ interface Acl { areAnyRolesAllowed: (roles: strings, resource: strings, permissions: strings, cb?: AllowedCallback) => Promise; whatResources: (roles: strings, permissions: strings, cb?: AnyCallback) => Promise; permittedResources: (roles: strings, permissions: strings, cb?: Function) => Promise; - middleware: (numPathComponents: number, userId: Value | GetUserId, actions: strings) => Promise; + middleware: (numPathComponents?: number, userId?: Value | GetUserId, actions?: strings) => express.RequestHandler; } interface Option {