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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Switching fast. Adapt everywhere.
**Switcher API** is a *Feature Flag* API with the main focus on decreasing the friction caused by changes while keeping control of what really matters.

Main features:
- Control & track more using little effort by sharing switchers among application components.
- Cross environment. Generate zero impact when manipulating your project features.
- Customizable environment strategies. Setup switchers using variables per environment.
- Delegate Switcher analysis to external services with secured Switcher Relay.
- Create manageable teams to collaborate.
- Keep track of every modification and features usage.
- Detailed metrics.
- SDKs support zero-latency mode for performance improvement.
- Exclusive Slack App to control and test changes.
- Easy to setup and seemless integration with your application using our lightweight Client SDKs.
- Shareable Switchers can be used across multiple applications with high support to observability.
- Multi-environment support. Create and manage features across different environments.
- Add extra layer of verification with custom conditions using Strategies.
- Delegate Switcher criteria decision to external services with Switcher Relay.
- Support to multiple teams and granular access control.
- Integrate with Slack usign Switcher Slack App to enable release flow requests.
- Detailed metrics and logs to help you understand how your features are being used.
- Open Source and free to use.


- **JS Client SDK**: (https://github.com/switcherapi/switcher-client-js)
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
"express-basic-auth": "^1.2.1",
"express-rate-limit": "^7.3.1",
"express-validator": "^7.1.0",
"graphql": "^16.8.2",
"graphql": "^16.9.0",
"graphql-http": "^1.22.1",
"graphql-tag": "^2.12.6",
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"mongodb": "^6.7.0",
"mongoose": "^8.4.3",
"mongodb": "^6.8.0",
"mongoose": "^8.4.4",
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"swagger-ui-express": "^5.0.1",
Expand All @@ -59,11 +59,11 @@
},
"devDependencies": {
"env-cmd": "^10.1.0",
"eslint": "^9.5.0",
"eslint": "^9.6.0",
"jest": "^29.7.0",
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
"nodemon": "^3.1.3",
"nodemon": "^3.1.4",
"sinon": "^18.0.0",
"supertest": "^7.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function responseException(res, err, code, feature = undefined) {
}

export function responseExceptionSilent(res, err, code, message) {
Logger.httpError(err.constructor.name, err.code, err.message, err);
Logger.httpError(err.constructor.name, err.code || code, message, err);

if (err.code) {
return res.status(err.code).send({ error: message });
Expand Down
6 changes: 5 additions & 1 deletion src/middleware/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ export async function auth(req, res, next) {
req.admin = admin;
next();
} catch (err) {
if (err.name === 'TokenExpiredError') {
return res.status(401).send({ error: 'Token expired.' });
}

responseExceptionSilent(res, err, 401, 'Please authenticate.');
}
}

export async function authRefreshToken(req, res, next) {
try {
const token = req.header('Authorization').replace('Bearer ', '');
const token = req.header('Authorization')?.replace('Bearer ', '');
const refreshToken = req.body.refreshToken;

const decodedRefreshToken = jwt.verify(refreshToken, process.env.JWT_SECRET);
Expand Down