Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

custom: https://www.paypal.me/kyberneees
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}