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
This commit is contained in:
wancat committed 2023-07-24 12:21:05 +08:00
1 parent c83ca750e1
commit 95fc25d0ad
7 files changed
+57 -15

No files matched your search

+4 -3
View File
@@ -27,9 +27,10 @@ export async function getContainer(id) {
return container
}
export async function getOrCreateContainer(name) {
export async function getOrCreateContainer(id) {
console.log(`Getting container: ${id}`)
try {
const container = engine.getContainer(name)
const container = engine.getContainer(id)
if (!(await container.inspect()).State.Running) {
await container.start()
}
@@ -37,7 +38,7 @@ export async function getOrCreateContainer(name) {
} catch (error) {
const container = await engine.createContainer({
...containerOptions,
name,
name: id,
})
await container.start()
console.log(container.id)