Refactor NocoDB settings to support dynamic table configuration and update related validation
All checks were successful
Build And Push Image / docker (push) Successful in 3m13s

This commit is contained in:
2025-08-07 20:43:39 +02:00
parent d0d7a34ae7
commit 22a74c6b33
6 changed files with 97 additions and 55 deletions

View File

@@ -32,10 +32,10 @@ export default defineEventHandler(async (event) => {
const body = await readBody(event) as NocoDBSettings;
// Validate required fields
if (!body.url || !body.apiKey || !body.baseId || !body.tableId) {
if (!body.url || !body.apiKey || !body.baseId || !body.tables) {
throw createError({
statusCode: 400,
statusMessage: 'All fields are required: url, apiKey, baseId, tableId'
statusMessage: 'All fields are required: url, apiKey, baseId, tables'
});
}
@@ -50,7 +50,7 @@ export default defineEventHandler(async (event) => {
console.log('[api/admin/nocodb-config.post] Saving NocoDB configuration...');
console.log('[api/admin/nocodb-config.post] URL:', body.url);
console.log('[api/admin/nocodb-config.post] Base ID:', body.baseId);
console.log('[api/admin/nocodb-config.post] Table ID:', body.tableId);
console.log('[api/admin/nocodb-config.post] Tables:', Object.keys(body.tables));
console.log('[api/admin/nocodb-config.post] API Key: [REDACTED]');
// Save configuration using the new admin config system

View File

@@ -32,10 +32,10 @@ export default defineEventHandler(async (event) => {
const body = await readBody(event) as NocoDBSettings;
// Validate required fields
if (!body.url || !body.apiKey || !body.baseId || !body.tableId) {
if (!body.url || !body.apiKey || !body.baseId || !body.tables || Object.keys(body.tables).length === 0) {
return {
success: false,
message: 'All fields are required to test connection'
message: 'All fields are required to test connection (url, apiKey, baseId, and at least one table)'
};
}
@@ -50,11 +50,13 @@ export default defineEventHandler(async (event) => {
console.log('[api/admin/nocodb-test.post] Testing NocoDB connection...');
console.log('[api/admin/nocodb-test.post] URL:', body.url);
console.log('[api/admin/nocodb-test.post] Base ID:', body.baseId);
console.log('[api/admin/nocodb-test.post] Table ID:', body.tableId);
console.log('[api/admin/nocodb-test.post] Tables:', Object.keys(body.tables));
try {
// Test connection by making a simple request to NocoDB
const testUrl = `${body.url}/api/v2/tables/${body.tableId}/records?limit=1`;
// Test connection by making a simple request to NocoDB using the first table
const firstTableName = Object.keys(body.tables)[0];
const firstTableId = body.tables[firstTableName];
const testUrl = `${body.url}/api/v2/tables/${firstTableId}/records?limit=1`;
console.log('[api/admin/nocodb-test.post] Testing URL:', testUrl);