feat: Setup Apache Cassandra

This commit is contained in:
April Hall 2025-01-08 17:44:20 -05:00
parent 3754648362
commit 881ddd1648
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C
4 changed files with 18 additions and 13 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -11,9 +11,7 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"db:migrate": "drizzle-kit generate --config drizzle.config.ts && drizzle-kit push --config drizzle.config.ts",
"db:studio": "drizzle-kit studio"
"lint": "prettier --check . && eslint ."
},
"devDependencies": {
"@eslint/compat": "^1.2.3",
@ -21,7 +19,6 @@
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"autoprefixer": "^10.4.20",
"drizzle-kit": "^0.22.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
@ -38,10 +35,9 @@
},
"dependencies": {
"@types/express": "^5.0.0",
"cassandra-driver": "^4.7.2",
"daisyui": "^4.12.23",
"drizzle-orm": "^0.33.0",
"express": "^4.21.2",
"postgres": "^3.4.4",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1",
"tsm": "^2.3.0"

View File

@ -1,6 +1,15 @@
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { env } from '$env/dynamic/private';
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
const client = postgres(env.DATABASE_URL);
export const db = drizzle(client);
import cassandra from 'cassandra-driver';
const client = new cassandra.Client({
contactPoints: ['localhost'],
localDataCenter: 'datacenter1',
keyspace: 'users',
});
// Connect to Cassandra/ScyllaDB and create
// necessary tables, keyspaces, etc
await client.connect();
await client.execute(`CREATE KEYSPACE IF NOT EXISTS users WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1};`);
await client.execute(`CREATE KEYSPACE IF NOT EXISTS channels WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 1};`);
export default client;

View File

@ -1,6 +1,6 @@
import { Server as SocketIOServer } from 'socket.io';
import type { HttpServer } from 'vite';
import { type TypeMessage } from './';
import client from './server/db/';
let io: SocketIOServer | undefined;