Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xAPI 2.0 Retrofit #53

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading