wancat 9f74a80551 feat: refactor session management and API usage
- Add an import statement for the `get` function from `./utils/env.js`
- Add a constant for `API_ENDPOINT` using the `get` function
- Remove the `sessionId` constant declaration
- Add an `async` function `getSessionId` for fetching session ID
- Add an `async` function `main` for the main program logic
- Initialize `sessionId` using the command line argument or by calling `getSessionId`
- Add a console log statement for the session ID
- Remove the `if` statement for checking `sessionId` existence
- Update the socket URL to use `API_ENDPOINT`
- Add a `socket.on` event listener for the `close` event
- Update the condition for checking the `key` value in `stdin.on` event listener
- Call the `main` function at the end of the file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:56:51 +08:00
2023-07-15 15:30:42 +08:00
2023-07-19 15:30:36 +08:00
2023-07-20 17:05:01 +08:00
2023-07-21 11:27:01 +08:00
2023-07-20 17:05:01 +08:00

Linux Odyssey

Requirements

  • NodeJS
  • Docker
  • Yarn

Installation

git clone https://github.com/lancatlin/linux-odyssey.git
cd linux-odyssey
yarn install

Create database

docker compose up -d

Server

Source: server/

yarn server
# Open http://localhost:3000

App

Source: app/

yarn app
# Open http://localhost:5173/

CLI terminal client

Open server first, then create a session by POST /api/v1/sessions

curl -X 'POST' \
  'http://localhost:3000/api/v1/sessions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "quest_id": "helloworld"
}'

Then use the _id field in response

yarn cli [_id]
# example
yarn cli 64be226a39c0043cd1cdf7c2
S
Description
No description provided
Readme GPL-3.0
8.1 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 64%
Vue 24.2%
Go 4.2%
Shell 2.1%
Handlebars 2.1%
Other 3.3%