fix: lib lefuturiste/express-redis-middleware

This commit is contained in:
Matthieu Bessat 2022-09-05 15:40:11 +02:00
parent 83f4aed5ea
commit 6ea2019b8f
5 changed files with 10181 additions and 7267 deletions

View file

@ -27,4 +27,15 @@ Then you have to fill the `.env`. We advise you to copy and paste the `.env.exam
## Usage in a production environment ## Usage in a production environment
`yarn serve` `yarn serve`
## Random notes
For lefuturiste/express-redis-middleware in package.json, if you want to do local development for the cache lib :
```json
{
"express-redis-cache": "portal:./../../express-redis-middleware/",
}
```

View file

@ -7,7 +7,7 @@
"@types/cors": "^2.8.6", "@types/cors": "^2.8.6",
"@types/events": "^3.0.0", "@types/events": "^3.0.0",
"@types/express": "^4.17.6", "@types/express": "^4.17.6",
"@types/express-redis-cache": "^1.1.0", "@types/express-redis-cache": "^1.1.2",
"@types/html-to-text": "^5.1.1", "@types/html-to-text": "^5.1.1",
"@types/http-proxy-middleware": "^0.19.3", "@types/http-proxy-middleware": "^0.19.3",
"@types/ioredis": "^4.17.0", "@types/ioredis": "^4.17.0",
@ -30,6 +30,7 @@
"crypto-random-string": "^3.2.0", "crypto-random-string": "^3.2.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"express-redis-cache": "git+https://github.com/lefuturiste/express-redis-middleware.git",
"html-to-text": "^5.1.1", "html-to-text": "^5.1.1",
"http-proxy-middleware": "^1.0.5", "http-proxy-middleware": "^1.0.5",
"ioredis": "^4.17.3", "ioredis": "^4.17.3",
@ -63,7 +64,7 @@
}, },
"main": "dist/index.js", "main": "dist/index.js",
"devDependencies": { "devDependencies": {
"cross-env": "^7.0.2", "cross-env": "^7.0.3",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-clean-css": "^4.3.0", "gulp-clean-css": "^4.3.0",
"gulp-minify": "^3.1.0", "gulp-minify": "^3.1.0",
@ -72,5 +73,6 @@
"nodemon": "^2.0.4", "nodemon": "^2.0.4",
"supertest": "^4.0.2" "supertest": "^4.0.2"
}, },
"version": "0.0.0" "version": "0.0.0",
"packageManager": "yarn@3.2.3"
} }

View file

@ -45,12 +45,9 @@ const cacheDuration = {
page: 3600 * 8 page: 3600 * 8
} }
let cache: any = { let cache: any
route: (x = null, y = null) => {
return (req: any, res: any, next: any) => { }
}
}
if (process.env.DISABLE_CACHE === 'true') { if (process.env.DISABLE_CACHE === 'true') {
console.log("> App: redis caching is disabled")
cache = { cache = {
route: (x = null, y = null) => { route: (x = null, y = null) => {
return (req: any, res: any, next: any) => { return (req: any, res: any, next: any) => {
@ -59,7 +56,9 @@ if (process.env.DISABLE_CACHE === 'true') {
} }
} }
} else { } else {
cache = ExpressRedisCache({ console.log("> App: redis caching is enabled")
// I won't go further with this, I will just use any for now...
cache = new (ExpressRedisCache as any)({
host: process.env.REDIS_HOST, host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT, port: process.env.REDIS_PORT,
auth_pass: process.env.REDIS_PASSWORD, auth_pass: process.env.REDIS_PASSWORD,

View file

@ -26,4 +26,4 @@ export default class ErrorController {
static internalError(req: express.Request, res: express.Response) { static internalError(req: express.Request, res: express.Response) {
console.log(res.locals.blabla.blabla) console.log(res.locals.blabla.blabla)
} }
} }

17414
yarn.lock

File diff suppressed because it is too large Load diff