coldown fix
This commit is contained in:
@@ -7,17 +7,21 @@ export interface IStorage {
|
||||
getPixel(x: number, y: number): Promise<Pixel | undefined>;
|
||||
getAllPixels(): Promise<Pixel[]>;
|
||||
placePixel(pixel: InsertPixel): Promise<Pixel>;
|
||||
|
||||
|
||||
// Config operations
|
||||
getCanvasConfig(): Promise<CanvasConfig>;
|
||||
updateCanvasConfig(config: InsertCanvasConfig): Promise<CanvasConfig>;
|
||||
|
||||
|
||||
// User cooldown operations
|
||||
getUserCooldown(userId: string): Promise<UserCooldown | undefined>;
|
||||
setUserCooldown(cooldown: InsertUserCooldown): Promise<UserCooldown>;
|
||||
|
||||
|
||||
// Recent activity
|
||||
getRecentPlacements(limit?: number): Promise<Pixel[]>;
|
||||
|
||||
// Admin operations
|
||||
deletePixel(pixelId: string): Promise<void>;
|
||||
clearCanvas(): Promise<void>;
|
||||
}
|
||||
|
||||
export class MemStorage implements IStorage {
|
||||
@@ -60,7 +64,7 @@ export class MemStorage implements IStorage {
|
||||
id,
|
||||
createdAt: new Date(),
|
||||
};
|
||||
|
||||
|
||||
this.pixels.set(this.getPixelKey(pixel.x, pixel.y), pixel);
|
||||
return pixel;
|
||||
}
|
||||
@@ -89,7 +93,7 @@ export class MemStorage implements IStorage {
|
||||
id,
|
||||
lastPlacement: new Date(),
|
||||
};
|
||||
|
||||
|
||||
this.userCooldowns.set(cooldown.userId, cooldown);
|
||||
return cooldown;
|
||||
}
|
||||
@@ -100,6 +104,21 @@ export class MemStorage implements IStorage {
|
||||
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
||||
async deletePixel(pixelId: string): Promise<void> {
|
||||
this.pixels.delete(pixelId);
|
||||
}
|
||||
|
||||
async clearCanvas(): Promise<void> {
|
||||
this.pixels.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export const storage = new MemStorage();
|
||||
// The SQLiteStorage import and usage below is not part of the changes,
|
||||
// but is included to ensure the file is complete as per instructions.
|
||||
import { SQLiteStorage } from "./sqlite-storage";
|
||||
|
||||
// Verwende SQLite im Development-Modus, Memory-Storage in Production
|
||||
export const storage = process.env.NODE_ENV === 'development'
|
||||
? new SQLiteStorage('./dev-database.sqlite')
|
||||
: new MemStorage();
|
||||
Reference in New Issue
Block a user