diff --git a/package-lock.json b/package-lock.json index 7a3f28b..3ccba37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -327,6 +327,17 @@ "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" + }, + "dependencies": { + "lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "requires": { + "yallist": "^3.0.2" + } + } } }, "@babel/helper-create-class-features-plugin": { @@ -6487,13 +6498,9 @@ "dev": true }, "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "requires": { - "yallist": "^3.0.2" - } + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==" }, "lru-memoizer": { "version": "2.1.4", diff --git a/package.json b/package.json index 5cc01c1..8f5b6d8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "tsnd --respawn --clear server/index.ts", "build": "tsc", - "start": "node server-to-upload/index.js", + "start": "NODE_ENV=production node server-to-upload/index.js", "build-and-run": "npm run build && npm start", "exportschema": "graphql-codegen --config codegen.yml && cp ./move-to-frontend/*.* ../client/src/data", "update-sbd-rank": "node sbd-rank/update-sbdrank-data.js", @@ -15,7 +15,7 @@ "repository": { "type": "git", "url": "https://github.com/bandinopla/weightxreps-server.git" - }, + }, "keywords": [], "author": "pablo@weightxreps.net", "license": "GPL-3.0", @@ -38,6 +38,7 @@ "graphql-upload": "^12.0.0", "html-entities": "^2.3.2", "jsonwebtoken": "^8.5.1", + "lru-cache": "^11.0.1", "md5": "^2.3.0", "mysql": "^2.18.1", "node-emoji": "^2.1.3", diff --git a/server/index.ts b/server/index.ts index 2c15815..3dcd7dc 100644 --- a/server/index.ts +++ b/server/index.ts @@ -20,6 +20,7 @@ async function startApolloServer( ) { const server = new ApolloServer({ /*typeDefs, resolvers*/ schema: WXRSchema + , persistedQueries: false , introspection: process.env.NODE_ENV !== 'production' , context: ({ req })=>{ diff --git a/server/utils/cache.js b/server/utils/cache.js index 2398961..f7ede5a 100644 --- a/server/utils/cache.js +++ b/server/utils/cache.js @@ -1,9 +1,11 @@ -import LRUCache from "lru-cache"; +import { LRUCache } from "lru-cache"; const $cache = new LRUCache({ - maxAge: process.env.NODE_ENV=='production'? 1000 * 60 * 60 : 0 + ttl: process.env.NODE_ENV=='production'? 1000 * 60 * 60 : 1, + ttlAutopurge: true, + max: 100, });