Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"migrate": "knex migrate:latest",
"migrate:rollback": "knex migrate:rollback",
"seed": "knex seed:run",
"etl": "ts-node src/scripts/run-etl.ts",
"lint": "eslint src --ext .ts",
"format": "prettier --write \"src/**/*.ts\""
},
Expand All @@ -24,7 +23,6 @@
"dependencies": {
"@azure/identity": "^4.0.1",
"@azure/keyvault-secrets": "^4.7.0",
"@neondatabase/serverless": "^0.9.0",
"axios": "^1.13.2",
"bcrypt": "^5.1.1",
"connect-redis": "^7.1.0",
Expand Down
9 changes: 6 additions & 3 deletions backend/src/database/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
throw new Error('DATABASE_URL environment variable is not set');
}

const isSupabase = connectionString.includes('supabase.co');
const config: PoolConfig = {
connectionString,
ssl: {
rejectUnauthorized: false
},
ssl: isSupabase ? {
rejectUnauthorized: false
} : connectionString.includes('sslmode=require') ? {
rejectUnauthorized: false
} : undefined,
max: parseInt(process.env.DB_POOL_MAX || '10'),
min: parseInt(process.env.DB_POOL_MIN || '2'),
idleTimeoutMillis: 30000,
Expand Down Expand Up @@ -86,9 +89,9 @@
}
};

export const queryWithRetry = async <T = any>(

Check warning on line 92 in backend/src/database/connection.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

Unexpected any. Specify a different type
queryText: string,
params?: any[],

Check warning on line 94 in backend/src/database/connection.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

Unexpected any. Specify a different type
maxRetries: number = 3
): Promise<T[]> => {
const pool = getDatabasePool();
Expand All @@ -98,7 +101,7 @@
try {
const result = await pool.query(queryText, params);
return result.rows;
} catch (error: any) {

Check warning on line 104 in backend/src/database/connection.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

Unexpected any. Specify a different type
lastError = error;

const isConnectionError =
Expand Down
21 changes: 21 additions & 0 deletions backend/src/database/migrations/009_add_mbid_to_music_items.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Knex } from 'knex';

export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable('music_items', (table) => {
table.uuid('mbid').nullable();
table.index('mbid');
});

await knex.raw(`
CREATE UNIQUE INDEX IF NOT EXISTS music_items_mbid_unique
ON music_items (mbid)
WHERE mbid IS NOT NULL
`);
}

export async function down(knex: Knex): Promise<void> {
await knex.schema.alterTable('music_items', (table) => {
table.dropIndex('mbid');
table.dropColumn('mbid');
});
}
71 changes: 0 additions & 71 deletions backend/src/database/seeds/002_seed_music_items.ts

This file was deleted.

5 changes: 0 additions & 5 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
verify: (req: express.Request, _res: express.Response, buf: Buffer) => {
const url = req.url || req.originalUrl || req.path;
if (url.includes('webhooks') || url.includes('interactions')) {
(req as any).rawBody = buf;

Check warning on line 38 in backend/src/index.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

Unexpected any. Specify a different type
}
}
}));
Expand Down Expand Up @@ -74,7 +74,6 @@
app.use(errorMiddleware);

import { testConnection } from './database/connection';
import { startETLScheduler } from './jobs/music-etl.job';

app.listen(PORT, async () => {
logger.info('Service: musiq-api');
Expand All @@ -87,10 +86,6 @@
} else {
logger.error('Database connection failed - check DATABASE_URL');
}

if (process.env.ENABLE_ETL === 'true') {
startETLScheduler();
}
});

export default app;
50 changes: 0 additions & 50 deletions backend/src/jobs/music-etl.job.ts

This file was deleted.

28 changes: 0 additions & 28 deletions backend/src/routes/admin.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
import { Router } from 'express';
import { authMiddleware, AuthRequest } from '../middleware/auth.middleware';

Check failure on line 2 in backend/src/routes/admin.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

'AuthRequest' is defined but never used

Check failure on line 2 in backend/src/routes/admin.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

'authMiddleware' is defined but never used
import { requireRole } from '../middleware/rbac.middleware';

Check failure on line 3 in backend/src/routes/admin.ts

View workflow job for this annotation

GitHub Actions / CI - Lint and Build

'requireRole' is defined but never used
import { runETLJobManually } from '../jobs/music-etl.job';
import { logger } from '../config/logger';

const router = Router();

router.post(
'/etl/run',
authMiddleware,
requireRole('admin'),
async (req: AuthRequest, res, next) => {
try {
logger.info('Manual ETL job triggered', { userId: req.userId });

runETLJobManually()
.then(() => {
logger.info('Manual ETL job completed');
})
.catch((error) => {
logger.error('Manual ETL job failed', { error });
});

res.json({
success: true,
message: 'ETL job started. Check logs for progress.',
});
} catch (error) {
next(error);
}
}
);

export default router;

20 changes: 0 additions & 20 deletions backend/src/scripts/run-etl.ts

This file was deleted.

Loading
Loading