Skip to content

Commit ada8713

Browse files
More fixes for the userinfo cache
1 parent c220535 commit ada8713

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ WORKDIR /usr/src/app
1212
COPY package*.json ./
1313

1414
# Install production dependencies.
15-
RUN yarn install --only=production
15+
RUN yarn install --production
1616

1717
# Copy local code to the container image.
18-
COPY . .
18+
COPY ./src ./src
19+
COPY ./conf ./conf
20+
COPY ./tsconfig.json .
1921
RUN chmod +x ./conf/startup.sh
2022

2123
RUN yarn build
2224

2325
# Run the web service on container startup.
24-
CMD [ "conf/startup.sh" ]
26+
CMD [ "./conf/startup.sh" ]

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"license": "UNLICENSED",
55
"private": true,
66
"description": "API for the RAnLab app",
7-
"main": "build/src/index.js",
7+
"main": "build/index.js",
88
"scripts": {
99
"build": "tsc --project .",
10+
"build-prod": "tsc ./src --project .",
1011
"test": "dev/test",
1112
"jest": "jest",
1213
"start": "node ."
@@ -26,6 +27,7 @@
2627
"@auth0/auth0-spa-js": "^1.13.6",
2728
"@google-cloud/firestore": "^4.9.9",
2829
"@types/hashring": "^3.2.1",
30+
"@types/node": "^12.12.67",
2931
"@types/node-fetch": "^2.5.8",
3032
"body-parser": "^1.19.0",
3133
"fastify": "^3.5.1",
@@ -39,16 +41,15 @@
3941
"jwks-rsa": "^1.12.0",
4042
"jwt-decode": "^3.1.2",
4143
"memcached-node": "^0.1.0",
42-
"node-fetch": "^2.6.1"
44+
"node-fetch": "^2.6.1",
45+
"typescript": "^4.0.3"
4346
},
4447
"devDependencies": {
4548
"@types/jest": "^26.0.15",
46-
"@types/node": "^12.12.67",
4749
"baretest": "^2.0.0",
4850
"jest": "^26.6.3",
4951
"memcached-mock": "^0.1.0",
5052
"ts-jest": "^26.4.4",
51-
"typemoq": "^2.1.0",
52-
"typescript": "^4.0.3"
53+
"typemoq": "^2.1.0"
5354
}
5455
}

src/auth0.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function verifyJwt(request: MinimalRequest, userCache: Memcached, getUserI
5454
let userData = await verifyJwtCached(cacheKey, userCache);
5555
if(!userData) {
5656
userData = await verifyJwtFromAuth0(authHeader, getUserInfo, getUserRole)
57-
await userCache.add(cacheKey, userData, {expires: LIFETIME_SECONDS});
57+
await userCache.set(cacheKey, userData, {mode: "json", expires: LIFETIME_SECONDS});
5858
}
5959
return userData;
6060
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import createUsersEndpoint from "./endpoints/users";
1616
import {createCacheEndpoint} from "./endpoints/cache";
1717
import {Memcached} from "memcached-node";
1818

19-
let productionCache = new Memcached("127.0.0.1:11211");
19+
let productionCache = new Memcached("127.0.0.1:11211", {wait:true});
2020
productionCache.createPool();
2121

2222
let productionDataLayer = new ProductionDataLayer(productionFirestore)

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@
2828
"esModuleInterop": true,
2929

3030
"forceConsistentCasingInFileNames": true
31-
}
31+
},
32+
"include": ["src/**/*"],
33+
"exclude": ["node_modules", "**/*.spec.ts"]
3234
}

0 commit comments

Comments
 (0)