{"id":22758808,"url":"https://github.com/TimSusa/ai-chat-upload-example","last_synced_at":"2025-08-09T00:31:23.125Z","repository":{"id":267446012,"uuid":"901268512","full_name":"TimSusa/ai-tool-belt","owner":"TimSusa","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-10T15:06:57.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-10T15:28:26.240Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimSusa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-10T10:52:33.000Z","updated_at":"2024-12-10T15:07:12.000Z","dependencies_parsed_at":"2024-12-10T15:38:27.498Z","dependency_job_id":null,"html_url":"https://github.com/TimSusa/ai-tool-belt","commit_stats":null,"previous_names":["timsusa/ai-tools","timsusa/ai-tool-belt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimSusa%2Fai-tool-belt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimSusa%2Fai-tool-belt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimSusa%2Fai-tool-belt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimSusa%2Fai-tool-belt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimSusa","download_url":"https://codeload.github.com/TimSusa/ai-tool-belt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229193776,"owners_count":18034497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-11T08:15:57.945Z","updated_at":"2025-08-09T00:31:23.106Z","avatar_url":"https://github.com/TimSusa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ai-chat-upload-example\n\nA collection of tools.\n\n![Screenshot 2024-12-10 at 15 23 06](https://github.com/user-attachments/assets/9b985104-0291-406b-b69a-fb1f5be75bce)\n\n\n## Features\n- **PDF Uploader**: From Client to Server\n- 🛠 **Server Sent Events**: SSE Server, sends back an answer\n\n## Prerequisites\n- **bun**: Ensure bun is installed.\n\n## Installation Dependencies\n\n```bash\nbun i\ncd client\nbun i\ncd ..\n```\n\n### **Usage of the State Event Manager**\n\n```typescript\n(async () =\u003e {\n    // Creating an Event Manager with In-Memory Adapter\n    const manager = new StateEventManager();\n\n    // Send events\n    manager.emit('userLogin', { username: 'JohnDoe', time: Date.now() });\n    manager.emit('errorLog', ['Error 404', 'Error 500']);\n    manager.emit('appStatus', 'running');\n    manager.emit('counter', 42);\n\n    // Listen for events\n    manager.on('userLogin', (payload) =\u003e {\n        console.log('User logged in:', payload);\n    });\n\n    manager.on('appStatus', (payload) =\u003e {\n        console.log('Application status:', payload);\n    });\n\n    // Save current state\n    await manager.saveState();\n\n    // Retrieve entire state\n    console.log('Entire State:', manager.getState());\n\n    // Load state\n    await manager.loadState();\n})();\n```\n\n### Usage Sqlite Adapter\n\n```typescript\n\n(async () =\u003e {\n  const sqliteAdapter = new SQLiteAdapter(\"./state.db\");\n  const manager = new StateEventManager(sqliteAdapter);\n\n  // Send events\n  manager.emit(\"userLogin\", { username: \"JaneDoe\", time: Date.now() });\n  manager.emit(\"appStatus\", \"stopped\");\n\n  // Save and load state\n  await manager.saveState();\n  await manager.loadState();\n  console.log(\"Loaded State:\", manager.getState());\n})();\n```\n\n### Usage Immutable State Event Proxy Manager\n\n```typescript\n// Example\nconst immutableState = new ImmutableStateManager({ theme: 'light', user: null });\n\nimmutableState.on('stateChanged', ({ oldState, newState }) =\u003e {\n  console.log('State updated:', oldState, '-\u003e', newState);\n});\n\nimmutableState.setState({ theme: 'dark' });\nconsole.log(immutableState.getState().theme); // Returns 'dark'\n\n// Direct attempt to change the state fails\ntry {\n  immutableState.getState().theme = 'light'; // Error: State is immutable\n} catch (e) {\n  console.error(e.message);\n}\n```\n\n### Server Start\n```bash\nbun start:server\n```\n\n### Client Start\n- Open a new console\n```bash\nbun start:client\n```\n\n## License\nThis project is licensed under the ISC License. See the LICENSE file for details.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTimSusa%2Fai-chat-upload-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTimSusa%2Fai-chat-upload-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTimSusa%2Fai-chat-upload-example/lists"}