feat: initialize frontend with Vite and PWA support

- Add index.html as the main entry point for the application.
- Create package.json to manage dependencies and scripts for development.
- Include favicon.svg for the application icon.
- Configure PWA assets generation with pwa-assets.config.js.
- Implement counter functionality in counter.js with notification on reaching 5.
- Add JavaScript logo SVG for branding.
- Set up main.js to render the application and handle user interactions.
- Create notification.js to manage browser notifications.
- Implement PWA registration and update handling in pwa.js.
- Style the application with a new style.css file.
- Configure Vite with PWA plugin in vite.config.js for service worker and manifest settings.
This commit is contained in:
2025-05-23 16:18:52 +02:00
commit 0394a7aceb
32 changed files with 2615 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import { Collection, Db, MongoClient, type Document } from 'mongodb';
import dbConfig from '../config/database';
class DatabaseService {
private client: MongoClient;
private db: Db | null = null;
private static instance: DatabaseService;
private constructor() {
this.client = new MongoClient(dbConfig.uri);
}
static getInstance(): DatabaseService {
if (!DatabaseService.instance) {
DatabaseService.instance = new DatabaseService();
}
return DatabaseService.instance;
}
async connect(): Promise<void> {
try {
await this.client.connect();
this.db = this.client.db(dbConfig.dbName);
console.log('Connected to MongoDB successfully');
} catch (error) {
console.error('Failed to connect to MongoDB', error);
throw error;
}
}
getCollection<T extends Document>(collectionName: string): Collection<T> {
if (!this.db) {
throw new Error('Database connection not established. Call connect() first.');
}
return this.db.collection<T>(collectionName);
}
async disconnect(): Promise<void> {
if (this.client) {
await this.client.close();
console.log('Disconnected from MongoDB');
}
}
}
export default DatabaseService;