Commit Graph
16 Commits
Author SHA1 Message Date
wancat 6ace18475b refactor: move client to sperate packages, rename cli to container 2023-08-21 20:40:05 +08:00
wancat 41a12c9aa8 feat: collect 2 level files info when ls
* change cli dir to /usr/local/lib/cli
* refactor cli to multiple files
* add handleCommand and listeners pattern
2023-08-21 20:40:05 +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 c3030b22be feat: add mongo init script, use root in app image 2023-07-31 17:19:03 +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 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 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 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 c83ca750e1 Connect to different shell 2023-07-22 16:35:44 +08:00
wancat 3e9e14399a Directly use folder name as _id in Quest 2023-07-20 16:25:10 +08:00
wancat 3637d41529 Load and update quests on startup 2023-07-20 15:08:47 +08:00
wancat b2173d180d Read all quest data in the folder 2023-07-19 20:01:14 +08:00
wancat d51a75e5bc Re-organize code 2023-07-18 20:33:08 +08:00