diff --git a/README.md b/README.md index 5f0ad65..ab31a6b 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/package.json b/package.json index e05e0f3..aabfc97 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" }, diff --git a/src/exceptions/index.js b/src/exceptions/index.js index a7ab6c9..257c0dd 100644 --- a/src/exceptions/index.js +++ b/src/exceptions/index.js @@ -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 }); diff --git a/src/middleware/auth.js b/src/middleware/auth.js index b52d1fc..895e97d 100644 --- a/src/middleware/auth.js +++ b/src/middleware/auth.js @@ -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);