feat: add ESLint and Prettier configuration for code quality

- Added ESLint with TypeScript support and custom rules.
- Introduced Prettier for consistent code formatting.
- Updated package.json to include lint and format scripts.
- Modified db.ts to ensure proper parsing of BIGINT types from PostgreSQL.
- Enhanced webRoutes to coerce timestamp fields to numbers and format isDeleted as boolean.
This commit is contained in:
2025-10-25 17:33:48 +02:00
parent 09a2b09913
commit 14c80197cc
13 changed files with 1620 additions and 44 deletions
+4 -1
View File
@@ -1,6 +1,6 @@
import dotenv from 'dotenv';
import BetterSqlite3, { Database as SqliteDB } from 'better-sqlite3';
import { Pool, PoolClient, QueryResult } from 'pg';
import { Pool, PoolClient, QueryResult, types as pgTypes } from 'pg';
import path from 'path';
import fs from 'fs';
@@ -129,6 +129,9 @@ class PostgresAdapter implements DBAdapter {
private pool: Pool;
constructor() {
// Ensure BIGINT (int8) is parsed as number to avoid string timestamps
// OID 20 = INT8, OID 1700 = NUMERIC (keep default for now)
pgTypes.setTypeParser(20, (val: string) => parseInt(val, 10));
const connectionString = process.env.DATABASE_URL;
if (connectionString) {
this.pool = new Pool({ connectionString });
+20 -3
View File
@@ -313,9 +313,26 @@ router.get('/web/data', async (req: Request, res: Response) => {
const values = await dbAdapter.queryAll('SELECT * FROM item_values');
// Convert isDeleted from INTEGER to BOOLEAN
const formattedLists = (lists as any[]).map(list => ({ ...list, isDeleted: !!list.isDeleted }));
const formattedFields = (fields as any[]).map(field => ({ ...field, isDeleted: !!field.isDeleted }));
const formattedItems = (items as any[]).map(item => ({ ...item, isDeleted: !!item.isDeleted }));
// Coerce timestamps to numbers (pg may return strings)
const toNum = (v: any) => (typeof v === 'string' ? Number(v) : v);
const formattedLists = (lists as any[]).map(list => ({
...list,
isDeleted: !!list.isDeleted,
createdAt: toNum(list.createdAt),
updatedAt: toNum(list.updatedAt)
}));
const formattedFields = (fields as any[]).map(field => ({
...field,
isDeleted: !!field.isDeleted,
createdAt: toNum(field.createdAt),
updatedAt: toNum(field.updatedAt)
}));
const formattedItems = (items as any[]).map(item => ({
...item,
isDeleted: !!item.isDeleted,
createdAt: toNum(item.createdAt),
updatedAt: toNum(item.updatedAt)
}));
res.json({
lists: formattedLists,