Configuración inicial del proyecto: estructura de directorios y dependencias mínimas instaladas
This commit is contained in:
79
scripts/list-databases.js
Normal file
79
scripts/list-databases.js
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const https = require('https');
|
||||
|
||||
const APPWRITE_ENDPOINT = 'https://appwrite.sunshinebestdeals.com/v1';
|
||||
const APPWRITE_PROJECT_ID = '693051e800374dd0a5b1';
|
||||
const APPWRITE_API_KEY = 'standard_b7ab9cd9f604fc98ab40f8c3472ba0bb27ea37c68567ec1b5c665de851aa66ee2c12a15b9f1f3a69d4d8c6cda4dbb0801150f749fdba052e8c822d82bd56b5ad75815d799ffd6a2ed21c3ed2432ececbfb65ca12e46dcb5b36e48557276463de9c6830dd8d966a549343dc60f5919be595d967568de21aa99621ff8e44dccf4a';
|
||||
|
||||
function listDatabases() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = new URL(`${APPWRITE_ENDPOINT}/databases`);
|
||||
|
||||
const options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port || 443,
|
||||
path: url.pathname,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-Appwrite-Project': APPWRITE_PROJECT_ID,
|
||||
'X-Appwrite-Key': APPWRITE_API_KEY,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(options, (res) => {
|
||||
let data = '';
|
||||
|
||||
res.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const json = JSON.parse(data);
|
||||
if (res.statusCode === 200) {
|
||||
resolve(json);
|
||||
} else {
|
||||
reject(new Error(`Error ${res.statusCode}: ${json.message || data}`));
|
||||
}
|
||||
} catch (e) {
|
||||
reject(new Error(`Error parsing response: ${e.message}\nResponse: ${data}`));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log('📊 Listando bases de datos de Appwrite...\n');
|
||||
const response = await listDatabases();
|
||||
|
||||
if (response.databases && response.databases.length > 0) {
|
||||
console.log(`✅ Encontradas ${response.databases.length} base(s) de datos:\n`);
|
||||
response.databases.forEach((db, index) => {
|
||||
console.log(`${index + 1}. ${db.name}`);
|
||||
console.log(` ID: ${db.$id}`);
|
||||
console.log(` Creada: ${new Date(db.$createdAt).toLocaleString()}`);
|
||||
console.log('');
|
||||
});
|
||||
|
||||
console.log(`Total: ${response.total} base(s) de datos`);
|
||||
} else {
|
||||
console.log('ℹ️ No se encontraron bases de datos en tu proyecto.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error al listar bases de datos:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user