File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
services/backend/src/routes/db Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 11import { type FastifyInstance , type FastifyRequest , type FastifyReply } from 'fastify' ;
22import { setupNewDatabase } from '../../db' ;
3+ import { getDbConfig } from '../../db/config' ;
34import {
45 InternalDbConfigSchema ,
56 DbSetupRequestBodySchema ,
@@ -16,6 +17,13 @@ async function setupDbHandler(
1617 server : FastifyInstance
1718) {
1819 try {
20+ // Check if DB is already configured
21+ const existingConfig = await getDbConfig ( ) ;
22+ if ( existingConfig ) {
23+ server . log . warn ( 'Attempt to set up an already configured database.' ) ;
24+ return reply . status ( 409 ) . send ( { message : 'Database setup has already been performed.' } ) ;
25+ }
26+
1927 const clientRequestBody = DbSetupRequestBodySchema . parse ( request . body ) ;
2028
2129 let internalConfigObject : InternalDbConfig ;
You can’t perform that action at this time.
0 commit comments