### Install Dependencies Source: https://github.com/vishalx360/pgondemand/blob/main/backend/README.md Installs the necessary Node.js dependencies for the session manager backend. Requires Node.js 18+ and a package manager like npm. ```bash git clone cd session-manager npm install ``` -------------------------------- ### Run Development Server (Next.js) Source: https://github.com/vishalx360/pgondemand/blob/main/frontend/README.md Commands to start the Next.js development server using various package managers. This enables local development with hot-reloading. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Run Application (Development) Source: https://github.com/vishalx360/pgondemand/blob/main/backend/README.md Starts the session manager backend application in development mode. This command is used for local development and testing. ```bash npm start ``` -------------------------------- ### Database Creation and Session API Source: https://github.com/vishalx360/pgondemand/blob/main/README.md This API documentation covers the process of creating a new PostgreSQL database instance and establishing a session. It includes the initial POST request to create a database and the subsequent WebSocket URL for interactive terminal access. ```APIDOC POST /api/create-db Description: Initiates the creation of a new PostgreSQL database. Request Body: Content-Type: application/json Schema: type: object properties: name: { type: string, description: "The desired name for the new database." } required: - name Example Request: POST /api/create-db Content-Type: application/json { "name": "example-db" } Success Response: Status: 200 OK Content-Type: application/json Schema: type: object properties: sessionId: { type: string, description: "Unique identifier for the user session." } websocketUrl: { type: string, description: "URL for the WebSocket connection to the container." } Example Response: { "sessionId": "abc123", "websocketUrl": "ws://ec2-instance/ws/abc123" } WebSocket Connection Description: Establishes a real-time connection to stream input/output between the frontend (e.g., xterm.js) and the PostgreSQL container. URL Format: ws:///ws/ Example: ws://ec2-instance/ws/abc123 Purpose: Facilitates interactive terminal sessions with the PostgreSQL container. ``` -------------------------------- ### Build and Run Docker Container Source: https://github.com/vishalx360/pgondemand/blob/main/backend/README.md Builds a Docker image for the session manager and runs it as a container. It maps port 3001 and mounts the Docker socket for container management. ```bash docker build -t session-manager . docker run -p 3001:3001 -v /var/run/docker.sock:/var/run/docker.sock session-manager ``` -------------------------------- ### Session Manager API Endpoints Source: https://github.com/vishalx360/pgondemand/blob/main/backend/README.md Defines the REST API endpoints for managing PostgreSQL database instances. These endpoints allow for creation, listing, and deletion of instances. ```APIDOC POST /api/create-db Description: Create a new PostgreSQL instance. Request Body: Content-Type: application/json Schema: type: object properties: name: { type: string, description: "The desired name for the new PostgreSQL instance." } Example: POST /api/create-db { "name": "my-pg-instance" } GET /api/list-dbs Description: List all active database instances managed by the service. Returns: Content-Type: application/json Schema: type: array items: { type: object, properties: { id: { type: string }, name: { type: string } } } # Example schema DELETE /api/delete-db/:id Description: Delete a specific database instance by its ID. Parameters: path: id: { type: string, description: "The unique identifier of the database instance to delete." } Example: DELETE /api/delete-db/a1b2c3d4e5f6 ``` -------------------------------- ### WebSocket Terminal Connection Source: https://github.com/vishalx360/pgondemand/blob/main/backend/README.md Establishes a WebSocket connection for terminal access to a running PostgreSQL instance. Requires the container ID of the target instance. ```websocket ws://:3001/ws/ ``` -------------------------------- ### Session Manager API Endpoints Source: https://github.com/vishalx360/pgondemand/blob/main/README.md Defines the REST API endpoints exposed by the Session Manager service for managing PostgreSQL database containers. These endpoints allow for creation, listing, and deletion of database instances. ```APIDOC Session Manager API: POST /api/create-db Description: Spins up a new PostgreSQL database container. Request Body: - databaseName (string): The desired name for the new database instance. Returns: - Success: Details of the created database instance (e.g., session ID, connection info). - Error: Appropriate error message if creation fails. GET /api/list-dbs Description: Lists all currently active database instances managed by the Session Manager. Returns: - Success: An array of active database instance metadata. - Error: Appropriate error message if listing fails. DELETE /api/delete-db/:id Description: Stops and removes a specific PostgreSQL database container. Parameters: - id (string): The unique identifier of the database instance to delete. Returns: - Success: Confirmation message that the instance was deleted. - Error: Appropriate error message if deletion fails or instance not found. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.