style: Prettier format

This commit is contained in:
April Hall 2025-01-13 08:36:41 -05:00
parent d3b8653c88
commit 12ad2431d8
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C
2 changed files with 7 additions and 6 deletions

View File

@ -4,8 +4,7 @@ function reverseArray(array: cassandra.types.Row[]) {
let left = null; let left = null;
let right = null; let right = null;
const length = array.length; const length = array.length;
for (left = 0, right = length - 1; left < right; left += 1, right -= 1) for (left = 0, right = length - 1; left < right; left += 1, right -= 1) {
{
const temporary = array[left]; const temporary = array[left];
array[left] = array[right]; array[left] = array[right];
array[right] = temporary; array[right] = temporary;
@ -34,7 +33,7 @@ async function storeMessage(client: cassandra.Client, channelName: string, conte
try { try {
const now = new Date(); const now = new Date();
await client.execute(`INSERT INTO channels.channel_${channelName} (id, message_content, channel_name, timestamp, sender) await client.execute(`INSERT INTO channels.channel_${channelName} (id, message_content, channel_name, timestamp, sender)
VALUES (${id}, '${content}', '${channelName}', ${now.getTime()}, ${sender})`); VALUES (${id}, '${content}', '${channelName}', ${now.getTime()}, ${sender})`);
} catch (e) { } catch (e) {
// @ts-expect-error I don't like this thing yelling at me // @ts-expect-error I don't like this thing yelling at me
console.log(`Error storing messages: ${e.message}`); console.log(`Error storing messages: ${e.message}`);
@ -43,8 +42,10 @@ async function storeMessage(client: cassandra.Client, channelName: string, conte
async function getMessages(client: cassandra.Client, channelName: string, limit: number) { async function getMessages(client: cassandra.Client, channelName: string, limit: number) {
try { try {
const res = await client.execute(`SELECT * FROM channels.channel_${channelName} WHERE channel_name = '${channelName}' ORDER BY timestamp DESC LIMIT ${limit}`); const res = await client.execute(
return reverseArray(res.rows) `SELECT * FROM channels.channel_${channelName} WHERE channel_name = '${channelName}' ORDER BY timestamp DESC LIMIT ${limit}`,
);
return reverseArray(res.rows);
} catch (e) { } catch (e) {
// @ts-expect-error I don't like this thing yelling at me // @ts-expect-error I don't like this thing yelling at me
console.log(`Error fetching messages: ${e.message}`); console.log(`Error fetching messages: ${e.message}`);

View File

@ -1,6 +1,6 @@
import { Server as SocketIOServer } from 'socket.io'; import { Server as SocketIOServer } from 'socket.io';
import type { HttpServer } from 'vite'; import type { HttpServer } from 'vite';
// Don't try to replace with $lib alias. Since this // Don't try to replace with $lib alias. Since this
// file gets loaded as a vite plugin, it will crash // file gets loaded as a vite plugin, it will crash
import { client, createChannel, storeMessage } from './server/db/'; import { client, createChannel, storeMessage } from './server/db/';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';