From ca70e68ffbbb3cb13cb48fb6745b994bfa71b747 Mon Sep 17 00:00:00 2001 From: calvintwr Date: Sat, 16 May 2020 07:32:26 +0800 Subject: [PATCH] [fix] ignore suffix. updated readme. --- index.js | 4 ++-- package.json | 2 +- readme.md | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 9dae5a9..818cc09 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ /*! - * Express Route-Magic v0.0.1 + * Express Route-Magic v0.0.3 * (c) 2020 Calvin Tan * Released under the MIT License. */ @@ -112,7 +112,7 @@ Magic.toIgnore = function (payload, isDirectory) { let toIgnore = false this.ignoreSuffix.forEach(suffix => { - if (payload.indexOf(suffix) !== -1 && payload.indexOf(suffix) !== payload.length - suffix.length) { + if (payload.indexOf(suffix) !== -1 && payload.indexOf(suffix) === payload.length - suffix.length) { toIgnore = true return null } diff --git a/package.json b/package.json index 8243047..032b541 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-routemagic", - "version": "0.0.2", + "version": "0.0.3", "description": "A simple and fast module to automatically require all your express routes without bloating your code without `app.use('i/will/repeat/this', require('./i/will/repeat/this')`.", "main": "index.js", "scripts": { diff --git a/readme.md b/readme.md index 75a7f3f..fda7358 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Route Magic -Route Magic is a simple and fast Nodejs module to abstract away the unnessary route invocations in the widely popular [Expressjs framework] (https://github.com/expressjs/express). +Route Magic is a simple and fast Nodejs module to abstract away the unnessary route invocations in the widely popular [Expressjs framework] (https://github.com/expressjs/express). This module has no dependencies. ## Say Goodbye To This @@ -18,7 +18,7 @@ This is the most basic way to use Magic: ```js const magic = require('express-routemagic') -magic.use(app, '[your route directory]') +magic.use(app, __dirname, '[your route directory]') ``` ## Installation @@ -30,7 +30,7 @@ npm install express-routemagic ## Options ```js -magic.use(app, { +magic.use(app, __dirname, { routeFolder: './routes', // Mandatory debug: [ your own debug module ], // Optional printRoutes: true, // Optional. This prints out all your routes. If no debug module is passed, it uses console.log by default @@ -44,7 +44,7 @@ magic.use(app, { ```js const debug = require('debug')('your:namespace:magic') -magic.use(app, { +magic.use(app, __dirname, { routeFolder: './routes', debug: debug, printRoutes: true, @@ -55,7 +55,7 @@ magic.use(app, { You can also pass an array to `ignoreSuffix`: ```js -magic.use(app, { +magic.use(app, __dirname, { ignoreSuffix: ['_bak', '_old', '_dev'] }) ```