diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..01d1325 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +custom: https://www.paypal.me/kyberneees diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9c3c2b2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..48d5f81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..2169838 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Have you contributed with at least a little donation to support the development of this project?** +- Paypal: https://www.paypal.me/kyberneees +- [TRON](https://www.binance.com/en/buy-TRON) Wallet: `TJ5Bbf9v4kpptnRsePXYDvnYcYrS5Tyxus` + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..f0a5433 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,21 @@ +name: tests +on: [push, pull_request] + +jobs: + testing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Setup Environment (Using NodeJS 16.x) + uses: actions/setup-node@v1 + with: + node-version: 16.x + + - name: Install dependencies + run: npm install + + - name: Linting + run: npx standard + + - name: Run tests + run: npm run test \ No newline at end of file diff --git a/README.md b/README.md index 3be6173..90036f7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ # middleware-if-unless Invokes connect-like middleware if / unless routing criteria matches. Inspired on [express-unless](https://www.npmjs.com/package/express-unless) module. +> ## Main features - Advanced routes matching capabilities. Uses [find-my-way](https://www.npmjs.com/package/find-my-way) or any compatible router to match the routes. -- `iff`: execute middleware only if the routes matches. Ideal use case: API gateways (see: [k-fastify-gateway](https://www.npmjs.com/package/k-fastify-gateway)) +- `iff`: execute middleware only if the routes matches. Ideal use case: API gateways (see: [fast-gateway](https://www.npmjs.com/package/fast-gateway)) - `unless`: execute middleware always unless the routes matches. - Arbitraty chaining of iff -> unless of vice-versa. - Low overhead, crazy fast implementation. diff --git a/index.js b/index.js index 4fc0cfe..1fb8477 100644 --- a/index.js +++ b/index.js @@ -25,7 +25,7 @@ module.exports = function (routerOpts = {}, routerFactory = require('find-my-way .map(endpoint => typeof endpoint === 'string' ? { url: endpoint } : endpoint) .forEach(({ methods = ['GET'], url, version, updateParams = false }) => { if (version) { - router.on(methods, url, { version }, handlers.match(updateParams)) + router.on(methods, url, { constraints: { version } }, handlers.match(updateParams)) } else { router.on(methods, url, handlers.match(updateParams)) } diff --git a/package.json b/package.json index dd0e43f..8dbc1d8 100644 --- a/package.json +++ b/package.json @@ -28,14 +28,14 @@ }, "homepage": "https://github.com/jkyberneees/middleware-if-unless#readme", "devDependencies": { - "chai": "^4.2.0", - "express-unless": "^0.5.0", - "mocha": "^8.2.1", - "nyc": "^14.1.1", - "restana": "^4.8.0", - "supertest": "^6.0.1" + "chai": "^4.3.6", + "express-unless": "^1.0.0", + "mocha": "^9.2.2", + "nyc": "^15.1.0", + "restana": "^4.9.4", + "supertest": "^6.2.2" }, "dependencies": { - "find-my-way": "^3.0.5" + "find-my-way": "^5.5.1" } }