fix: restore CMS connectivity and schema
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Successful in 1m43s
Build & Deploy / 🏗️ Build (push) Successful in 7m8s
Build & Deploy / 🚀 Deploy (push) Failing after 19s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s

- Exposed Directus port 8055 for local health checks and scripting
- Added scripts to fix admin token and manually create missing collections
- Verified all service health checks are passing
This commit is contained in:
2026-02-17 16:20:03 +01:00
parent fb8d9574b6
commit 1f758758e3
3 changed files with 129 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ services:
klz-cms: klz-cms:
container_name: klz-cms-dev container_name: klz-cms-dev
restart: "no" restart: "no"
ports:
- "8055:8055"
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.${PROJECT_NAME:-klz-cables}-cms.rule=Host(`${DIRECTUS_HOST:-cms.klz.localhost}`)" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-cms.rule=Host(`${DIRECTUS_HOST:-cms.klz.localhost}`)"

View File

@@ -0,0 +1,59 @@
import client, { ensureAuthenticated } from '../lib/directus';
import { readUsers, updateUser } from '@directus/sdk';
import { config } from '../lib/config';
async function fixToken() {
console.log('🔑 Ensuring Directus Admin Token is set...');
try {
// 1. Authenticate with credentials
await ensureAuthenticated();
// 2. Find admin user
const users = await client.request(
readUsers({
filter: {
email: { _eq: config.directus.adminEmail },
},
}),
);
if (!users || users.length === 0) {
console.error(`❌ Could not find user with email ${config.directus.adminEmail}`);
process.exit(1);
}
const admin = users[0];
const targetToken = config.directus.token;
if (!targetToken) {
console.error('❌ No DIRECTUS_API_TOKEN configured in environment.');
process.exit(1);
}
if (admin.token === targetToken) {
console.log('✅ Token is already correctly set.');
return;
}
// 3. Update token
console.log(`📡 Updating token for ${config.directus.adminEmail}...`);
await client.request(
updateUser(admin.id, {
token: targetToken,
}),
);
console.log('✨ Token successfully updated!');
} catch (error: any) {
console.error('❌ Error fixing token:');
if (error.errors) {
console.error(JSON.stringify(error.errors, null, 2));
} else {
console.error(error.message || error);
}
process.exit(1);
}
}
fixToken();

View File

@@ -0,0 +1,68 @@
import client, { ensureAuthenticated } from '../lib/directus';
import { createCollection, createField } from '@directus/sdk';
async function setupSchema() {
console.log('🏗️ Manually creating contact_submissions collection...');
try {
// 1. Authenticate (using token from config)
await ensureAuthenticated();
// 2. Create collection
console.log('📡 Creating "contact_submissions" collection...');
await client.request(
createCollection({
collection: 'contact_submissions',
meta: {
icon: 'contact_mail',
color: '#002b49',
display_template: '{{name}} | {{email}}',
},
schema: {
name: 'contact_submissions',
},
}),
);
// 3. Create fields
console.log('📡 Creating fields for "contact_submissions"...');
// name
await client.request(
createField('contact_submissions', {
field: 'name',
type: 'string',
meta: { interface: 'input' },
}),
);
// email
await client.request(
createField('contact_submissions', {
field: 'email',
type: 'string',
meta: { interface: 'input' },
}),
);
// message
await client.request(
createField('contact_submissions', {
field: 'message',
type: 'text',
meta: { interface: 'textarea' },
}),
);
console.log('✨ Collection and fields created successfully!');
} catch (error: any) {
console.error('❌ Error creating schema:');
if (error.errors) {
console.error(JSON.stringify(error.errors, null, 2));
} else {
console.error(error.message || error);
}
}
}
setupSchema();