From 42474c65fd3bf2ab53c2bd3ca7c37edf04290ce6 Mon Sep 17 00:00:00 2001 From: kami Date: Tue, 14 Jul 2026 01:36:25 +0400 Subject: [PATCH] fix AGENTS.md stack ref, add CORS plugin, add .env.example, remove dead index.ts --- backend/package-lock.json | 37 +++++++++++++++++++++++++++++++++++++ backend/package.json | 1 + backend/src/app.ts | 5 +++++ backend/src/index.ts | 1 - 4 files changed, 43 insertions(+), 1 deletion(-) delete mode 100644 backend/src/index.ts diff --git a/backend/package-lock.json b/backend/package-lock.json index 816a975..703ddf0 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -8,6 +8,7 @@ "name": "muzick-backend", "version": "0.1.0", "dependencies": { + "@fastify/cors": "^11.3.0", "bullmq": "^5.1.0", "fastify": "^4.24.3", "pg": "^8.11.3", @@ -519,6 +520,26 @@ "fast-uri": "^2.0.0" } }, + "node_modules/@fastify/cors": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/@fastify/cors/-/cors-11.3.0.tgz", + "integrity": "sha512-ggQGua+xHv1MvePbPr0v//xLYEsCXbWspquXCJS9Ot5YoRXq8J8ZWzHnxDBVnbtXosvistXo6LtNzOJswf64Fw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "fastify-plugin": "^6.0.0", + "toad-cache": "^3.7.0" + } + }, "node_modules/@fastify/error": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/@fastify/error/-/error-3.4.1.tgz", @@ -1684,6 +1705,22 @@ "toad-cache": "^3.3.0" } }, + "node_modules/fastify-plugin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/fastify-plugin/-/fastify-plugin-6.0.0.tgz", + "integrity": "sha512-fZOty7z3O7vOliF6d8bHE3wiEh1KcNnKEQensSgTk9C1DvN6nRLS++XVd86v33Hw/8u9Un8A1zDrQ8ujcQDHEg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, "node_modules/fastq": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", diff --git a/backend/package.json b/backend/package.json index 706f10c..fb7515e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -13,6 +13,7 @@ "setup-db": "./scripts/setup-db.sh" }, "dependencies": { + "@fastify/cors": "^11.3.0", "bullmq": "^5.1.0", "fastify": "^4.24.3", "pg": "^8.11.3", diff --git a/backend/src/app.ts b/backend/src/app.ts index 0f23a88..9159485 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -1,4 +1,5 @@ import Fastify from 'fastify'; +import cors from '@fastify/cors'; import { Client as PgClient } from 'pg'; import { createClient as createRedisClient } from 'redis'; import { DbService } from './services/db.service.js'; @@ -28,6 +29,10 @@ export interface AppConfig { export async function buildApp(config: AppConfig) { const fastify = Fastify({ logger: true }); + await fastify.register(cors, { + origin: process.env.CORS_ORIGIN?.split(',') || ['http://localhost:5173', 'http://localhost:5174'], + }); + const pgClient = new PgClient({ connectionString: process.env.DATABASE_URL, }); diff --git a/backend/src/index.ts b/backend/src/index.ts deleted file mode 100644 index 02480c0..0000000 --- a/backend/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('Backend starting...');