Skip to content

Commit b650497

Browse files
authored
Merge pull request #53 from adlnet/preload-user-prefs
xAPI 2.0 Retrofit
2 parents 31258fd + afb781a commit b650497

17 files changed

+2724
-391
lines changed

cts/.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PLAYER_TOKEN_SECRET=player-token-secret
1010
LRS_ENDPOINT=http://host.docker.internal:8081/20.1.x/lrs/default/
1111
LRS_USERNAME=dev-tools-xapi
1212
LRS_PASSWORD=dev-tools-xapi-password
13+
LRS_XAPI_VERSION=1.0.3
1314

1415
## Dev Only, set to 0 to allow self-signed certs
1516
NODE_TLS_REJECT_UNAUTHORIZED=1

cts/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ COPY --chown=node:node entrypoint.sh /usr/src/app
2626
COPY --chown=node:node service /usr/src/app
2727
COPY --chown=node:node migrations /usr/src/app/migrations
2828
COPY --chown=node:node --from=client-build /usr/src/app/dist /usr/src/app/client
29-
RUN npm ci --only=production
29+
RUN rm package-lock.json && npm install && npm ci --only=production
3030
RUN npm install -g nodemon
3131
USER node
3232
ENTRYPOINT []

cts/docker-compose.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545

4646
webservice:
4747
build: .
48-
image: catapult:cts
48+
container_name: docker_cts
4949
restart: always
5050
ports:
5151
- 127.0.0.1:3399:3399
@@ -67,12 +67,16 @@ services:
6767
- PLAYER_KEY
6868
- PLAYER_SECRET
6969
- NODE_TLS_REJECT_UNAUTHORIZED
70+
- LRS_ENDPOINT
71+
- LRS_USERNAME
72+
- LRS_PASSWORD
73+
- LRS_XAPI_VERSION
7074
networks:
7175
- public
7276

7377
player:
7478
build: ../player
75-
image: catapult:player
79+
container_name: docker_player
7680
restart: always
7781
depends_on:
7882
- rdbms
@@ -95,6 +99,7 @@ services:
9599
- LRS_ENDPOINT
96100
- LRS_USERNAME
97101
- LRS_PASSWORD
102+
- LRS_XAPI_VERSION
98103
- TOKEN_SECRET=${PLAYER_TOKEN_SECRET}
99104
- API_KEY=${PLAYER_KEY}
100105
- API_SECRET=${PLAYER_SECRET}

cts/service/index.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const Hapi = require("@hapi/hapi"),
2727
{
2828
PLAYER_BASE_URL: PLAYER_BASE_URL = "http://player:3398",
2929
PLAYER_KEY,
30-
PLAYER_SECRET
30+
PLAYER_SECRET,
31+
LRS_ENDPOINT,
32+
LRS_USERNAME,
33+
LRS_PASSWORD
3134
} = process.env;
3235

3336
const provision = async () => {
@@ -109,6 +112,25 @@ const provision = async () => {
109112
]
110113
);
111114

115+
server.method(
116+
"lrsWreckDefaults",
117+
(req) => ({
118+
baseUrl: LRS_ENDPOINT.endsWith("/") ? LRS_ENDPOINT : LRS_ENDPOINT + "/",
119+
headers: {
120+
"X-Experience-API-Version": (process.env.LRS_XAPI_VERSION || "1.0.3"),
121+
Authorization: `Basic ${Buffer.from(`${LRS_USERNAME}:${LRS_PASSWORD}`).toString("base64")}`
122+
},
123+
json: true
124+
}),
125+
{
126+
generateKey: (req) => `${LRS_ENDPOINT}-${LRS_USERNAME}-${LRS_PASSWORD}`,
127+
cache: {
128+
expiresIn: 60000,
129+
generateTimeout: 1000
130+
}
131+
}
132+
);
133+
112134
server.method(
113135
"getCredentials",
114136
(user) => {

0 commit comments

Comments
 (0)