From 5fd0df813550ef4e4778d5e705c20fb9fb2dbd35 Mon Sep 17 00:00:00 2001 From: Daniel McCrystal Date: Tue, 5 Aug 2025 00:26:05 -0400 Subject: [PATCH] arangodb --- docker-compose.yaml | 14 +++ package.json | 11 +- pnpm-lock.yaml | 169 ++++++++++++++++++------------- src/db.ts | 32 +++--- src/routes/[game]/[instance].tsx | 9 +- src/routes/[game]/index.tsx | 27 +++-- src/routes/index.tsx | 14 +-- sync_db.ts | 43 ++++++++ 8 files changed, 203 insertions(+), 116 deletions(-) create mode 100644 docker-compose.yaml create mode 100644 sync_db.ts diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..bea4a6f --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,14 @@ +version: "3.8" +services: + arangodb: + image: arangodb/arangodb:latest + ports: + - "8529:8529" + environment: + ARANGO_ROOT_PASSWORD: pass + volumes: + - arangodb_data:/var/lib/arangodb3 + - arangodb_apps:/var/lib/arangodb3-apps +volumes: + arangodb_data: + arangodb_apps: diff --git a/package.json b/package.json index a0d6c8c..106b69f 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,13 @@ "scripts": { "dev": "vinxi dev", "build": "vinxi build", - "start": "vinxi start" + "start": "vinxi start", + "sync_db": "tsx ./sync_db.ts" }, "dependencies": { "@solidjs/router": "^0.15.3", "@solidjs/start": "^1.1.0", - "kefir": "^3.8.8", - "kefir-bus": "^2.3.1", - "lowdb": "^7.0.1", + "arangojs": "^10.1.2", "solid-js": "^1.9.5", "vinxi": "^0.5.7" }, @@ -20,6 +19,8 @@ "node": ">=22" }, "devDependencies": { - "@types/kefir": "^3.8.11" + "@types/json-schema": "^7.0.15", + "json-schema": "^0.4.0", + "tsx": "^4.20.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6efced4..922aa9c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,26 +13,26 @@ importers: version: 0.15.3(solid-js@1.9.7) '@solidjs/start': specifier: ^1.1.0 - version: 1.1.7(solid-js@1.9.7)(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1))(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)) - kefir: - specifier: ^3.8.8 - version: 3.8.8 - kefir-bus: - specifier: ^2.3.1 - version: 2.3.1(kefir@3.8.8) - lowdb: - specifier: ^7.0.1 - version: 7.0.1 + version: 1.1.7(solid-js@1.9.7)(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) + arangojs: + specifier: ^10.1.2 + version: 10.1.2 solid-js: specifier: ^1.9.5 version: 1.9.7 vinxi: specifier: ^0.5.7 - version: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1) + version: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) devDependencies: - '@types/kefir': - specifier: ^3.8.11 - version: 3.8.11 + '@types/json-schema': + specifier: ^7.0.15 + version: 7.0.15 + json-schema: + specifier: ^0.4.0 + version: 0.4.0 + tsx: + specifier: ^4.20.3 + version: 4.20.3 packages: @@ -947,8 +947,8 @@ packages: '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} - '@types/kefir@3.8.11': - resolution: {integrity: sha512-5TRdFXQYsVUvqIH6nYjslHzBgn4hnptcutXnqAhfbKdWD/799c44hFhQGF3887E2t/Q4jSp3RvNFCaQ+b9w6vQ==} + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} '@types/mdast@4.0.4': resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} @@ -956,6 +956,9 @@ packages: '@types/micromatch@4.0.9': resolution: {integrity: sha512-7V+8ncr22h4UoYRLnLXSpTxjQrNUXtWHGeMPRJt1nULXI57G9bIcpyrHlmrQ7QK24EyyuXvYcSSWAM8GA9nqCg==} + '@types/node@20.19.9': + resolution: {integrity: sha512-cuVNgarYWZqxRJDQHEB58GEONhOK79QVR/qYx4S7kcUObQvUwvFnYxJuuHUKm2aieN9X3yZB4LZsuYNU1Qphsw==} + '@types/node@24.1.0': resolution: {integrity: sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==} @@ -1120,6 +1123,15 @@ packages: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} + arangojs@10.1.2: + resolution: {integrity: sha512-25Gy2dwSYOaKNWJixpGZXCSeOxS+k/E0sFuADcYm9ZhywFYwsTgh2hOB83fZy0ZOhC7Xc/zEhOL+tR6wujoyfQ==} + engines: {node: '>=20'} + peerDependencies: + undici: '>=5.21.0' + peerDependenciesMeta: + undici: + optional: true + archiver-utils@5.0.2: resolution: {integrity: sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==} engines: {node: '>= 14'} @@ -1795,6 +1807,9 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} + get-tsconfig@4.10.1: + resolution: {integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==} + giget@2.0.0: resolution: {integrity: sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==} hasBin: true @@ -2031,6 +2046,9 @@ packages: engines: {node: '>=6'} hasBin: true + json-schema@0.4.0: + resolution: {integrity: sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==} + json5@2.2.3: resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} engines: {node: '>=6'} @@ -2044,14 +2062,6 @@ packages: resolution: {integrity: sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==} engines: {node: '>=18'} - kefir-bus@2.3.1: - resolution: {integrity: sha512-wLCQfEw8PddSNeyjDCH2WNgNg3Rb/c+OaG5WEPfEwod+LQfGX4isHcHRWsYNLmdFEw3/KyA+9qDSy+VC4NsifA==} - peerDependencies: - kefir: ^3.5.1 - - kefir@3.8.8: - resolution: {integrity: sha512-xWga7QCZsR2Wjy2vNL3Kq/irT+IwxwItEWycRRlT5yhqHZK2fmEhziP+LzcJBWSTAMranGKtGTQ6lFpyJS3+jA==} - kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} @@ -2106,10 +2116,6 @@ packages: resolution: {integrity: sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==} engines: {node: '>= 12.0.0'} - lowdb@7.0.1: - resolution: {integrity: sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==} - engines: {node: '>=18'} - lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -2575,6 +2581,9 @@ packages: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + resolve@1.22.10: resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} engines: {node: '>= 0.4'} @@ -2771,10 +2780,6 @@ packages: std-env@3.9.0: resolution: {integrity: sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==} - steno@4.0.2: - resolution: {integrity: sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==} - engines: {node: '>=18'} - streamx@2.22.1: resolution: {integrity: sha512-znKXEBxfatz2GBNK02kRnCXjV+AA4kjZIUxeWSr3UGirZMJfTE9uiwKHobnbgxWyL/JWro8tTq+vOqAK1/qbSA==} @@ -2897,6 +2902,11 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tsx@4.20.3: + resolution: {integrity: sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==} + engines: {node: '>=18.0.0'} + hasBin: true + type-fest@4.41.0: resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} engines: {node: '>=16'} @@ -2921,6 +2931,9 @@ packages: undici-types@5.28.4: resolution: {integrity: sha512-3OeMF5Lyowe8VW0skf5qaIE7Or3yS9LS7fvMUI0gg4YxpIBVg0L8BxCmROw2CcYhSkpR68Epz7CGc8MPj94Uww==} + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + undici-types@7.8.0: resolution: {integrity: sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==} @@ -4021,11 +4034,11 @@ snapshots: dependencies: solid-js: 1.9.7 - '@solidjs/start@1.1.7(solid-js@1.9.7)(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1))(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1))': + '@solidjs/start@1.1.7(solid-js@1.9.7)(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))': dependencies: - '@tanstack/server-functions-plugin': 1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)) - '@vinxi/plugin-directives': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)) - '@vinxi/server-components': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)) + '@tanstack/server-functions-plugin': 1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) + '@vinxi/plugin-directives': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) + '@vinxi/server-components': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) defu: 6.1.4 error-stack-parser: 2.1.4 html-to-image: 1.11.13 @@ -4036,8 +4049,8 @@ snapshots: source-map-js: 1.2.1 terracotta: 1.0.6(solid-js@1.9.7) tinyglobby: 0.2.14 - vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1) - vite-plugin-solid: 2.11.8(solid-js@1.9.7)(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)) + vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) + vite-plugin-solid: 2.11.8(solid-js@1.9.7)(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) transitivePeerDependencies: - '@testing-library/jest-dom' - solid-js @@ -4046,7 +4059,7 @@ snapshots: '@speed-highlight/core@1.2.7': {} - '@tanstack/directive-functions-plugin@1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1))': + '@tanstack/directive-functions-plugin@1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))': dependencies: '@babel/code-frame': 7.26.2 '@babel/core': 7.28.0 @@ -4055,7 +4068,7 @@ snapshots: '@tanstack/router-utils': 1.129.7 babel-dead-code-elimination: 1.0.10 tiny-invariant: 1.3.3 - vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1) + vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) transitivePeerDependencies: - supports-color @@ -4070,7 +4083,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@tanstack/server-functions-plugin@1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1))': + '@tanstack/server-functions-plugin@1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))': dependencies: '@babel/code-frame': 7.26.2 '@babel/core': 7.28.0 @@ -4079,7 +4092,7 @@ snapshots: '@babel/template': 7.27.2 '@babel/traverse': 7.28.0 '@babel/types': 7.28.2 - '@tanstack/directive-functions-plugin': 1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)) + '@tanstack/directive-functions-plugin': 1.121.21(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) babel-dead-code-elimination: 1.0.10 tiny-invariant: 1.3.3 transitivePeerDependencies: @@ -4115,9 +4128,7 @@ snapshots: dependencies: '@types/unist': 3.0.3 - '@types/kefir@3.8.11': - dependencies: - '@types/node': 24.1.0 + '@types/json-schema@7.0.15': {} '@types/mdast@4.0.4': dependencies: @@ -4127,9 +4138,14 @@ snapshots: dependencies: '@types/braces': 3.0.5 + '@types/node@20.19.9': + dependencies: + undici-types: 6.21.0 + '@types/node@24.1.0': dependencies: undici-types: 7.8.0 + optional: true '@types/normalize-package-data@2.4.4': {} @@ -4221,7 +4237,7 @@ snapshots: untun: 0.1.3 uqr: 0.1.2 - '@vinxi/plugin-directives@0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1))': + '@vinxi/plugin-directives@0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))': dependencies: '@babel/parser': 7.28.0 acorn: 8.15.0 @@ -4232,18 +4248,18 @@ snapshots: magicast: 0.2.11 recast: 0.23.11 tslib: 2.8.1 - vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1) + vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) - '@vinxi/server-components@0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1))': + '@vinxi/server-components@0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3))': dependencies: - '@vinxi/plugin-directives': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)) + '@vinxi/plugin-directives': 0.5.1(vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) acorn: 8.15.0 acorn-loose: 8.5.2 acorn-typescript: 1.4.13(acorn@8.15.0) astring: 1.9.0 magicast: 0.2.11 recast: 0.23.11 - vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1) + vinxi: 0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) '@vue/compiler-core@3.5.18': dependencies: @@ -4352,6 +4368,10 @@ snapshots: normalize-path: 3.0.0 picomatch: 2.3.1 + arangojs@10.1.2: + dependencies: + '@types/node': 20.19.9 + archiver-utils@5.0.2: dependencies: glob: 10.4.5 @@ -5006,6 +5026,10 @@ snapshots: get-stream@8.0.1: {} + get-tsconfig@4.10.1: + dependencies: + resolve-pkg-maps: 1.0.0 + giget@2.0.0: dependencies: citty: 0.1.6 @@ -5236,18 +5260,14 @@ snapshots: jsesc@3.1.0: {} + json-schema@0.4.0: {} + json5@2.2.3: {} junk@4.0.1: {} jwt-decode@4.0.0: {} - kefir-bus@2.3.1(kefir@3.8.8): - dependencies: - kefir: 3.8.8 - - kefir@3.8.8: {} - kleur@4.1.5: {} klona@2.0.6: {} @@ -5316,10 +5336,6 @@ snapshots: safe-stable-stringify: 2.5.0 triple-beam: 1.4.1 - lowdb@7.0.1: - dependencies: - steno: 4.0.2 - lru-cache@10.4.3: {} lru-cache@5.1.1: @@ -5874,6 +5890,8 @@ snapshots: resolve-from@5.0.0: {} + resolve-pkg-maps@1.0.0: {} + resolve@1.22.10: dependencies: is-core-module: 2.16.1 @@ -6120,8 +6138,6 @@ snapshots: std-env@3.9.0: {} - steno@4.0.2: {} - streamx@2.22.1: dependencies: fast-fifo: 1.3.2 @@ -6248,6 +6264,13 @@ snapshots: tslib@2.8.1: {} + tsx@4.20.3: + dependencies: + esbuild: 0.25.8 + get-tsconfig: 4.10.1 + optionalDependencies: + fsevents: 2.3.3 + type-fest@4.41.0: {} typescript@5.8.3: {} @@ -6267,7 +6290,10 @@ snapshots: undici-types@5.28.4: {} - undici-types@7.8.0: {} + undici-types@6.21.0: {} + + undici-types@7.8.0: + optional: true unenv@1.10.0: dependencies: @@ -6420,7 +6446,7 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1): + vinxi@0.5.8(@netlify/blobs@9.1.2)(@types/node@24.1.0)(db0@0.3.2)(ioredis@5.6.1)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3): dependencies: '@babel/core': 7.28.0 '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.28.0) @@ -6454,7 +6480,7 @@ snapshots: unctx: 2.4.1 unenv: 1.10.0 unstorage: 1.16.1(@netlify/blobs@9.1.2)(db0@0.3.2)(ioredis@5.6.1) - vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1) + vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) zod: 3.25.76 transitivePeerDependencies: - '@azure/app-configuration' @@ -6498,7 +6524,7 @@ snapshots: - xml2js - yaml - vite-plugin-solid@2.11.8(solid-js@1.9.7)(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)): + vite-plugin-solid@2.11.8(solid-js@1.9.7)(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)): dependencies: '@babel/core': 7.28.0 '@types/babel__core': 7.20.5 @@ -6506,12 +6532,12 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.9.7 solid-refresh: 0.6.3(solid-js@1.9.7) - vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1) - vitefu: 1.1.1(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)) + vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) + vitefu: 1.1.1(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)) transitivePeerDependencies: - supports-color - vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1): + vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3): dependencies: esbuild: 0.25.8 fdir: 6.4.6(picomatch@4.0.3) @@ -6524,10 +6550,11 @@ snapshots: fsevents: 2.3.3 jiti: 2.5.1 terser: 5.43.1 + tsx: 4.20.3 - vitefu@1.1.1(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)): + vitefu@1.1.1(vite@6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3)): optionalDependencies: - vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1) + vite: 6.3.5(@types/node@24.1.0)(jiti@2.5.1)(terser@5.43.1)(tsx@4.20.3) web-streams-polyfill@3.3.3: {} diff --git a/src/db.ts b/src/db.ts index 51b1044..e19ae9e 100644 --- a/src/db.ts +++ b/src/db.ts @@ -1,23 +1,17 @@ "use server"; -import { JSONFilePreset } from "lowdb/node"; -import { GameState, newGame } from "./types/cards"; -type schema = { - games: { - [key: string]: { - name: string; - rules: string; - instances: { [id: string]: GameState }; - }; - }; -}; -const _db = await JSONFilePreset("db.json", { - games: { - renaissance: { - name: "renaissance", - rules: "", - instances: { test: newGame() }, - }, +import { Database } from "arangojs"; +import { GameState, newGame } from "./types/cards"; +import { AqlQuery } from "arangojs/aql"; + +const db = new Database({ + url: "http://localhost:8529", + auth: { + username: "root", + password: "pass", }, + databaseName: "prod", }); -export const db = async () => _db.read().then(() => _db.data); + +export const query = async (q: AqlQuery) => + await db.query(q).then((c) => c.all()); diff --git a/src/routes/[game]/[instance].tsx b/src/routes/[game]/[instance].tsx index 28f9d7e..73de752 100644 --- a/src/routes/[game]/[instance].tsx +++ b/src/routes/[game]/[instance].tsx @@ -1,14 +1,15 @@ import { useParams } from "@solidjs/router"; -import { db } from "../../db"; + import { createEffect, createResource, Show, Suspense } from "solid-js"; import Game from "../../components/Game"; +import { aql } from "arangojs"; export default () => { const params = useParams(); - const [instance] = createResource(() => - db().then((data) => data.games[params.game].instances[params.instance]) - ); + const [instance] = createResource(async () => { + return null; + }); return ( diff --git a/src/routes/[game]/index.tsx b/src/routes/[game]/index.tsx index e75e50c..e896469 100644 --- a/src/routes/[game]/index.tsx +++ b/src/routes/[game]/index.tsx @@ -1,7 +1,8 @@ import { A, useParams } from "@solidjs/router"; import { createEffect, createResource, For, Suspense } from "solid-js"; -import { db } from "../../db"; +import { query } from "../../db"; +import { aql } from "arangojs"; export default () => { const params = useParams(); @@ -11,22 +12,26 @@ export default () => { const [instances] = createResource( () => params.game, () => - db().then((data) => { - if (params.game == null) { - return {}; - } - return data.games[params.game].instances; - }) + query<{ _id: string }>( + aql` + FOR i IN instances + FILTER i.name == ${params.game} + RETURN i + ` + ) ); + + createEffect(() => console.log(instances())); + return (

{params.game}

    - - {([instanceId]) => ( - - {instanceId} + + {(instance) => ( + + {instance._id} )} diff --git a/src/routes/index.tsx b/src/routes/index.tsx index cde83c8..7a9998d 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,14 +1,16 @@ import { A } from "@solidjs/router"; -import Game from "../components/Game"; -import { createResource, For } from "solid-js"; -import { db } from "../db"; +import { For } from "solid-js"; export default () => { - const [games] = createResource(() => db().then((data) => data.games)); + const games = [ + { + name: "renaissance", + }, + ]; return (
    - - {([gameId, game]) => {game.name}} + + {(game) => {game.name}}
    ); diff --git a/sync_db.ts b/sync_db.ts new file mode 100644 index 0000000..35e64c7 --- /dev/null +++ b/sync_db.ts @@ -0,0 +1,43 @@ +import { Database, aql } from "arangojs"; +import { DocumentCollection, SchemaOptions } from "arangojs/collections"; +import { EnsurePersistentIndexOptions } from "arangojs/indexes"; +import { JSONSchema7 } from "json-schema"; +// It's good practice to specify the URL. +// We connect to the _system database first to check if our target DB exists. +const sysdb = new Database({ + url: "http://localhost:8529", + auth: { + username: "root", + password: "pass", + }, +}); + +const db = sysdb.database("prod"); + +const ent = async ( + name: string, + schema?: SchemaOptions, + index?: EnsurePersistentIndexOptions +) => { + const col = db.collection(name); + + // @ts-ignore + + await col.exists().then((e) => e || db.createCollection(name)); + + schema && col.properties({ schema }); + index && col.ensureIndex(index); + + return col; +}; + +const Games = ent("games", { + rule: { + type: "object", + properties: { + name: { type: "string" }, + }, + } as JSONSchema7, +}); +const Instances = ent("instances"); +const Humans = ent("humans");