mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 07:40:10 +00:00
Loosen too restrictive typings for path property, add missing ext property
This commit is contained in:
@@ -9,3 +9,9 @@ var middleware: unless.RequestHandler = function(req, res, next) {
|
||||
middleware.unless = unless;
|
||||
app.use(middleware.unless({ method: "OPTIONS" }));
|
||||
app.use(middleware.unless(req => req.path === "test"));
|
||||
|
||||
app.use(middleware.unless({ path: "/index", useOriginalUrl: true }));
|
||||
app.use(middleware.unless({ path: /home/g, ext: ".jpg" }));
|
||||
app.use(middleware.unless({ path: { url: "/index" }, ext: [ ".html", ".htm" ] }));
|
||||
app.use(middleware.unless({ path: { url: "/index", methods: [ "GET", "POST" ] } }));
|
||||
app.use(middleware.unless({ path: [ "/index", "/home", /home/i, { url: "/main", methods: [ "GET" ] }, { url: /home/i } ] }));
|
||||
6
types/express-unless/index.d.ts
vendored
6
types/express-unless/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://www.npmjs.org/package/express-unless
|
||||
// Definitions by: Wonshik Kim <https://github.com/wokim>
|
||||
// Joao Vieira <https://github.com/joaovieira>
|
||||
// Michal Kaminski <https://github.com/michal-b-kaminski>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -11,11 +12,14 @@ declare function unless(options: unless.Options): express.RequestHandler;
|
||||
declare function unless(options: unless.Options["custom"]): express.RequestHandler;
|
||||
|
||||
declare namespace unless {
|
||||
type pathFilter = string | RegExp | { url: string | RegExp, methods?: string[] };
|
||||
|
||||
export interface Options {
|
||||
custom?: (req: express.Request) => boolean;
|
||||
path?: string | string[];
|
||||
path?: pathFilter | pathFilter[];
|
||||
ext?: string | string[];
|
||||
method?: string | string[];
|
||||
useOriginalUrl?: boolean;
|
||||
}
|
||||
export interface RequestHandler extends express.RequestHandler {
|
||||
unless?: typeof unless;
|
||||
|
||||
Reference in New Issue
Block a user