function registerPublicConfigRoutes(app, { cloudClientConfig }) {
  app.get('/api/public-config', (_req, res) => {
    res.json(cloudClientConfig.getCloudClientConfig());
  });

  app.post('/api/public-config', (req, res) => {
    const nextConfig = cloudClientConfig.writeCloudConfigFile(req.body || {});
    res.json({
      ...cloudClientConfig.getCloudClientConfig(),
      ...nextConfig,
      authReady: Boolean(nextConfig.cloudApiUrl && nextConfig.supabaseUrl && nextConfig.supabasePublishableKey)
    });
  });
}

module.exports = { registerPublicConfigRoutes };
