Commit Graph
75 Commits
Author SHA1 Message Date
wancat 0ba823b432 feat: print hints 2023-08-09 21:16:43 +08:00
wancat a151d2d667 feat: add type and color to response 2023-08-09 21:14:57 +08:00
wancat 5cad3ecc12 fix: mark progress to stage.next directly 2023-08-08 20:38:27 +08:00
wancat a73aa8b461 fix: prevent execute command twice 2023-08-08 20:38:27 +08:00
wancat 41a090ce73 doc: update README 2023-08-08 20:38:27 +08:00
wancat 6f368f761e feat: add hints to session, update API 2023-08-08 20:38:27 +08:00
wancat ae61bfc768 Update eslint rule 2023-08-08 20:38:27 +08:00
wancat 094332da53 feat: add commandHandler 2023-08-08 20:38:27 +08:00
wancat 0de4b6ac9d feat: design game file and parse it to mongo
* 取消用 README 來寫關卡說明
2023-08-08 20:38:27 +08:00
wancat 6204bd0b17 feat: change to use Zsh
* show message from server response
* send output and error to server
2023-08-08 20:38:27 +08:00
wancat 0153eae673 feat: new cli client to send and receive msg from api 2023-08-08 20:38:27 +08:00
wancat e2e585329f Create a pty cli, not useful 2023-08-08 20:38:27 +08:00
wancat 12a42d117c feat: write story of the game 2023-08-08 20:38:27 +08:00
Lin, Hung-Shin edfe197e51 Merge pull request #8 from lancatlin/hot-fix-server-socket
fix: send string
2023-08-08 20:37:08 +08:00
wancat 06ee53f194 fix: send string 2023-08-08 20:36:49 +08:00
Lin, Hung-Shin fb826c2f0e Merge pull request #6 from lancatlin/app-neil
Front-end update
2023-08-01 20:56:20 +08:00
wancat d26e68098a fix: use PascalCase 2023-08-01 20:54:49 +08:00
Chen, Tai-Lin 8b151c443d Revise variable names and file names 2023-08-01 20:54:49 +08:00
wancat 66cc1036b4 feat: use axios, extract api to another file 2023-08-01 20:54:49 +08:00
Chen, Tai-Lin a40e9eb3a9 Reorganize front-end code 2023-08-01 20:54:05 +08:00
Chen, Tai-Lin 06220e6b30 import fontawesome api 2023-08-01 20:54:05 +08:00
Chen, Tai-Lin 5e6cb7be37 fetch quest api 2023-08-01 20:54:05 +08:00
Lin, Hung-Shin b729e30e0b Merge pull request #5 from lancatlin/server-commands-api
Server commands api
2023-07-31 17:22:36 +08:00
wancat c3030b22be feat: add mongo init script, use root in app image 2023-07-31 17:19:03 +08:00
wancat ec90c484b4 feat: add parameters and subcommand to client.js
- Added `"commander": "^11.0.0"` as a dependency in the `package.json` file
- Added an `import { program } from 'commander'` statement in the `client.js` file
- Modified the `createdSession` function in the `client.js` file to use `program.opts().host` instead of `API_ENDPOINT`
- Added a `getSessionList` function in the `client.js` file to fetch the list of sessions
- Added a `lastSession` function in the `client.js` file to get the last session from the session list
- Added a `connect` function in the `client.js` file to establish a socket connection
- Modified the `main` function in the `client.js` file to use `program.opts().session` instead of `process.argv[2]` to get the session ID
- Modified the `main` function in the `client.js` file to use `program.opts().host` instead of `API_ENDPOINT` to initialize the socket connection
- Added a `program` object with options and actions in the `client.js` file
- Added `.bash_history` to the `.gitignore` file
- Added `.viminfo` to the `.gitignore` file
- Added `*.swp` to the `.gitignore` file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-31 15:42:58 +08:00
wancat b9643e7d5c feat: capture output and exit code of commands
+ ignore interactive commands like vim, top or nano
2023-07-27 17:56:32 +08:00
wancat d997a061a9 feat: send command typed in container to API
- Modify the Dockerfile in the `server/quests/helloworld` directory to add a user and change the working directory
- Rename the file `server/quests/helloworld/entrypoint.sh` to `server/quests/helloworld/home/.bashrc`
- Modify the `server/src/config.js` file to add the `isProduction` flag
- Modify the `server/src/utils/docker.js` file to add a `HostConfig` option and bind a directory if not in production mode
- Modify the Dockerfile to add an argument `DOCKER_GID` and create a group and user with the specified `DOCKER_GID`
- Add a new Dockerfile.dev file with the same modifications as the Dockerfile
- Add a new file `inspect.sh`
- Modify the `server/src/client.js` file to use the `API_ENDPOINT` variable instead of a hardcoded URL

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-26 20:54:01 +08:00
wancat 9376e16f72 Success to send command to api
+ require sourcing entrypoint.sh manually
2023-07-26 00:12:10 +08:00
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
wancat 88ed447573 fix: error handling
- Remove unnecessary try-catch block in createSession function
- Add error handling for missing session ID in socket.js
- Improve error handling in connectDB function
- Add error handling middleware for server errors
- Add default export for get function in env.js

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:46:59 +08:00
wancat 943c11714c feat: connect containers to custom network
- Export the `get` function in `utils/env.js`
- Change the Docker image in `docker.js` from `ubuntu` to `lancatlin/quest-helloworld`
- Remove the `createContainer` and `getContainer` functions from `docker.js`
- Add a `network` constant in `docker.js` that gets the Docker network from the config
- Connect the container to the network in `getOrCreateContainer` function in `docker.js`
- Add `API_ENDPOINT` environment variable in the `attachContainer` function in `docker.js`

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:42:07 +08:00
wancat 189c87df5a build: setup Docker dev configuration
- Add `.dockerignore` file
- Add `Dockerfile.dev`
- Modify `docker-compose.yml`:
  - Add `restart: on-failure` to `app` service
  - Modify `build` section of `app` service
  - Remove `links` section from `app` service
  - Add `networks` section to `app` and `db` services
  - Add `networks` section to the end of the file

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-25 15:37:05 +08:00
wancat 3cea54ce71 feat: add new API for recording executed commands
- Add the `jsonwebtoken` dependency to the server's `package.json`
- Add a new file `commandController.js` to the server's API controllers
- Add a new route `/commands` to the server's API routes
- Add a new file `commands.js` to the server's API routes
- Modify the `index.js` file in the server's API routes to import and use the `commands.js` route
- Add a `newCommand` function to the `commandController.js` file
- Add a `Command` model to the `command.js` file in the server's models
- Add the `genSessionJWT` and `verifySessionJWT` functions to the `auth.js` file in the server's utils
- Modify the `attachContainer` function in the `docker.js` file in the server's utils to include a `token` parameter
- Modify the `swagger.yaml` file to include a new route `/commands` for recording executed commands in a session

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-24 16:39:04 +08:00
wancat fe3f4ddc73 fix: docker image name update 2023-07-24 16:39:04 +08:00
Lin, Hung-Shin 9ee9a8586f Merge pull request #3 from lancatlin/server-terminal-api
Server terminal api
2023-07-24 15:09:02 +08:00
wancat 5fd611ab51 docs: improve comments and remove unnecessary lines
- Add a comment about creating a session with a POST request to `/api/v1/sessions`
- Remove the line mentioning `yarn cli` command
- Add a comment about using the `_id` field in the response
- Remove the example usage of `yarn cli`

Signed-off-by: wancat <wancat@wancat.cc>
2023-07-24 15:06:48 +08:00
wancat 95fc25d0ad feat: connect to different container by sessions
Based on the file summaries provided, the best label for this commit would be "feat". This is because the commit introduces several new features to the codebase, such as adding a new ESLint rule, adding a new property to a function, adding authentication middleware, adding a query parameter, and adding a new function to handle user authentication.: update authentication and session handling

- Add `"camelcase"` rule to ESLint configuration
- Add `containerId` property to the `newSession` object in the `createSession` function
- Add authentication middleware to the socket.io connection
- Add a query parameter `session_id` to the socket.io connection in `client.js`
- Add `defaultUser` function to handle user authentication
- Update the `authMiddleware` function to use the `defaultUser` function
- Add `defaultUser` function to handle user authentication in `auth.js`
- Update `getOrCreateContainer` function to use the `id` parameter instead of `name` parameter
2023-07-24 12:21:05 +08:00
wancat 41030e246c Disable Tailscale and use SSH directly 2023-07-22 16:38:51 +08:00
wancat c83ca750e1 Connect to different shell 2023-07-22 16:35:44 +08:00
Lin, Hung-Shin 4a74127785 Merge pull request #2 from lancatlin/app-neil
Add Learning Page UI in App.vue
2023-07-21 19:38:42 +08:00
Chen, Tai-Lin 589b0736b9 merge Learning Page UI prototype into App.vue 2023-07-21 18:02:51 +08:00
Chen, Tai-Lin de47d2585a Learning Page UI prototype 2023-07-21 16:44:14 +08:00
Lin, Hung-Shin b39c5395e3 Update ci_cd.yml 2023-07-21 11:59:11 +08:00
wancat 6d8163f6a6 Add github action 2023-07-21 11:53:04 +08:00
wancat 2dffd2f74d Add config.js, dockerfile 2023-07-21 11:27:01 +08:00
Lin, Hung-Shin 4ffdb5d627 Merge pull request #1 from lancatlin/server-justin
Add Quests and Sessions API
2023-07-20 21:55:52 +08:00
wancat c4e14fa271 Update README, format script 2023-07-20 17:05:01 +08:00
wancat 5410254ee0 Finish get single and delete api for sessions 2023-07-20 16:30:58 +08:00
wancat 43f54b4f93 Create and get session list api 2023-07-20 16:25:54 +08:00
wancat 3e9e14399a Directly use folder name as _id in Quest 2023-07-20 16:25:10 +08:00