-
{{ questErr.message }}
-
{{ questData.instruction }}
+
+
{{ questData.instruction }}
+
+
Tasks:
+
+
+
{{ questErr.message }}
Loading...
diff --git a/app/src/utils/session.js b/app/src/utils/session.js
index b731d43..1bf5a21 100644
--- a/app/src/utils/session.js
+++ b/app/src/utils/session.js
@@ -35,6 +35,10 @@ class SessionManager {
}
}
+ setTasks(tasks) {
+ this.session.value.tasks = tasks
+ }
+
async createSession() {
console.log('Creating a new session...')
const res = await api.post('/sessions', { quest_id: this.questId })
diff --git a/docker-compose.yml b/docker-compose.yml
index 3492bab..47d371a 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -54,6 +54,12 @@ services:
context: .
dockerfile: quests/helloworld/Dockerfile
+ base:
+ image: lancatlin/linux-odyssey:base
+ build:
+ context: .
+ dockerfile: ./quests/Dockerfile
+
networks:
internal:
players:
diff --git a/packages/client/index.js b/packages/client/index.js
index 5363631..99ec410 100644
--- a/packages/client/index.js
+++ b/packages/client/index.js
@@ -1,8 +1,11 @@
/* eslint-disable no-underscore-dangle */
+import axios from 'axios'
import { stdin, stdout, exit } from 'process'
import { io } from 'socket.io-client'
import { program } from 'commander'
+let api = null
+
function get(key, defaultValue) {
const value = process.env[key]
if (value != null) {
@@ -14,26 +17,29 @@ stdin.setRawMode(true)
stdin.resume()
stdin.setEncoding('utf8')
-async function createdSession() {
+function debug(...args) {
+ if (program.opts().debug) {
+ console.debug(...args)
+ }
+}
+
+async function createSession() {
console.log('Creating a new session...')
- const res = await fetch(`${program.opts().host}/api/v1/sessions`, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- quest_id: 'helloworld',
- }),
+ const res = await api.post('/sessions', {
+ quest_id: 'helloworld',
})
- const data = await res.json()
+ const { data } = await res
+ if (!data._id) {
+ console.error(data)
+ exit(1)
+ }
console.log('Created Session ID:', data._id)
return data
}
async function getSessionList() {
- const res = await fetch(`${program.opts().host}/api/v1/sessions`)
- const data = await res.json()
- return data
+ const res = await api.get('/sessions')
+ return res.data
}
async function lastSession() {
@@ -73,8 +79,11 @@ async function connect(sessionId) {
})
socket.on('graph', (data) => {
- console.log('receive graph:')
- console.log(data)
+ debug('receive graph:', data)
+ })
+
+ socket.on('tasks', (data) => {
+ debug('receive tasks:', data)
})
socket.on('close', function close() {
@@ -93,12 +102,18 @@ async function connect(sessionId) {
}
async function main() {
+ api = axios.create({
+ baseURL: `${program.opts().host}/api/v1`,
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
console.log(program.opts().session)
// main()
const sessionId =
program.opts().session ||
- (program.opts().create ? (await createdSession())._id : null) ||
+ (program.opts().create ? (await createSession())._id : null) ||
(await lastSession())._id
await connect(sessionId)
@@ -107,6 +122,7 @@ async function main() {
program
.option('-s, --session