Skip to content

Commit

Permalink
Merge pull request #53 from adlnet/preload-user-prefs
Browse files Browse the repository at this point in the history
xAPI 2.0 Retrofit
  • Loading branch information
vbhayden authored May 21, 2024
2 parents 31258fd + afb781a commit b650497
Show file tree
Hide file tree
Showing 17 changed files with 2,724 additions and 391 deletions.
1 change: 1 addition & 0 deletions cts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PLAYER_TOKEN_SECRET=player-token-secret
LRS_ENDPOINT=http://host.docker.internal:8081/20.1.x/lrs/default/
LRS_USERNAME=dev-tools-xapi
LRS_PASSWORD=dev-tools-xapi-password
LRS_XAPI_VERSION=1.0.3

## Dev Only, set to 0 to allow self-signed certs
NODE_TLS_REJECT_UNAUTHORIZED=1
2 changes: 1 addition & 1 deletion cts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ COPY --chown=node:node entrypoint.sh /usr/src/app
COPY --chown=node:node service /usr/src/app
COPY --chown=node:node migrations /usr/src/app/migrations
COPY --chown=node:node --from=client-build /usr/src/app/dist /usr/src/app/client
RUN npm ci --only=production
RUN rm package-lock.json && npm install && npm ci --only=production
RUN npm install -g nodemon
USER node
ENTRYPOINT []
Expand Down
9 changes: 7 additions & 2 deletions cts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:

webservice:
build: .
image: catapult:cts
container_name: docker_cts
restart: always
ports:
- 127.0.0.1:3399:3399
Expand All @@ -67,12 +67,16 @@ services:
- PLAYER_KEY
- PLAYER_SECRET
- NODE_TLS_REJECT_UNAUTHORIZED
- LRS_ENDPOINT
- LRS_USERNAME
- LRS_PASSWORD
- LRS_XAPI_VERSION
networks:
- public

player:
build: ../player
image: catapult:player
container_name: docker_player
restart: always
depends_on:
- rdbms
Expand All @@ -95,6 +99,7 @@ services:
- LRS_ENDPOINT
- LRS_USERNAME
- LRS_PASSWORD
- LRS_XAPI_VERSION
- TOKEN_SECRET=${PLAYER_TOKEN_SECRET}
- API_KEY=${PLAYER_KEY}
- API_SECRET=${PLAYER_SECRET}
Expand Down
24 changes: 23 additions & 1 deletion cts/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const Hapi = require("@hapi/hapi"),
{
PLAYER_BASE_URL: PLAYER_BASE_URL = "http://player:3398",
PLAYER_KEY,
PLAYER_SECRET
PLAYER_SECRET,
LRS_ENDPOINT,
LRS_USERNAME,
LRS_PASSWORD
} = process.env;

const provision = async () => {
Expand Down Expand Up @@ -109,6 +112,25 @@ const provision = async () => {
]
);

server.method(
"lrsWreckDefaults",
(req) => ({
baseUrl: LRS_ENDPOINT.endsWith("/") ? LRS_ENDPOINT : LRS_ENDPOINT + "/",
headers: {
"X-Experience-API-Version": (process.env.LRS_XAPI_VERSION || "1.0.3"),
Authorization: `Basic ${Buffer.from(`${LRS_USERNAME}:${LRS_PASSWORD}`).toString("base64")}`
},
json: true
}),
{
generateKey: (req) => `${LRS_ENDPOINT}-${LRS_USERNAME}-${LRS_PASSWORD}`,
cache: {
expiresIn: 60000,
generateTimeout: 1000
}
}
);

server.method(
"getCredentials",
(user) => {
Expand Down
Loading

0 comments on commit b650497

Please sign in to comment.