Fix CloudFront domain configuration and add missing color definitions
- Configure CloudFront to accept filamenteka.rs with ACM SSL certificate - Add Cloudflare Transform Rule for Host header rewriting - Fix Matte Grass Green hex code (#7CB342 -> #61C680) - Add PLA Wood colors: Ochre Yellow, White Oak, Clay Brown - Add script for managing color definitions in database
This commit is contained in:
92
scripts/add-missing-colors.js
Normal file
92
scripts/add-missing-colors.js
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
const { Pool } = require('pg');
|
||||||
|
|
||||||
|
const connectionString = "postgresql://filamenteka_admin:onrBjiAjHKQXBAJSVWU2t2kQ7HDil9re@filamenteka.ci7fsdlbzmag.eu-central-1.rds.amazonaws.com:5432/filamenteka";
|
||||||
|
|
||||||
|
const pool = new Pool({
|
||||||
|
connectionString,
|
||||||
|
ssl: { rejectUnauthorized: false }
|
||||||
|
});
|
||||||
|
|
||||||
|
const missingColors = [
|
||||||
|
// PLA Matte - New colors with correct hex codes
|
||||||
|
{ name: "Matte Dark Chocolate", hex: "#4A3729", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Dark Brown", hex: "#7D6556", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Terracotta", hex: "#A25A37", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Caramel", hex: "#A4845C", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Dark Blue", hex: "#042F56", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Sky Blue", hex: "#73B2E5", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Ice Blue", hex: "#A3D8E1", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Dark Green", hex: "#68724D", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Grass Green", hex: "#61C680", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Apple Green", hex: "#C6E188", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Dark Red", hex: "#BB3D43", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Plum", hex: "#851A52", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Lilac Purple", hex: "#AE96D4", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Sakura Pink", hex: "#E8AFCF", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Lemon Yellow", hex: "#F7D959", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Matte Bone White", hex: "#C8C5B6", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
|
||||||
|
// PLA Wood colors
|
||||||
|
{ name: "Ochre Yellow", hex: "#BC8B39", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "White Oak", hex: "#D2CCA2", cena_refill: 3499, cena_spulna: 3999 },
|
||||||
|
{ name: "Clay Brown", hex: "#8E621A", cena_refill: 3499, cena_spulna: 3999 }
|
||||||
|
];
|
||||||
|
|
||||||
|
async function addMissingColors() {
|
||||||
|
try {
|
||||||
|
console.log('🎨 Adding missing colors to database...\n');
|
||||||
|
|
||||||
|
let added = 0;
|
||||||
|
let updated = 0;
|
||||||
|
let skipped = 0;
|
||||||
|
|
||||||
|
for (const color of missingColors) {
|
||||||
|
try {
|
||||||
|
// Check if color already exists
|
||||||
|
const existingColor = await pool.query(
|
||||||
|
'SELECT * FROM colors WHERE name = $1',
|
||||||
|
[color.name]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingColor.rows.length > 0) {
|
||||||
|
// Update existing color with correct hex code
|
||||||
|
const existing = existingColor.rows[0];
|
||||||
|
if (existing.hex !== color.hex) {
|
||||||
|
await pool.query(
|
||||||
|
'UPDATE colors SET hex = $1, cena_refill = $2, cena_spulna = $3 WHERE name = $4',
|
||||||
|
[color.hex, color.cena_refill, color.cena_spulna, color.name]
|
||||||
|
);
|
||||||
|
console.log(`✅ Updated: ${color.name} (${existing.hex} → ${color.hex})`);
|
||||||
|
updated++;
|
||||||
|
} else {
|
||||||
|
console.log(`⏭️ Skipped: ${color.name} (already exists with correct hex)`);
|
||||||
|
skipped++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Insert new color
|
||||||
|
await pool.query(
|
||||||
|
'INSERT INTO colors (name, hex, cena_refill, cena_spulna) VALUES ($1, $2, $3, $4)',
|
||||||
|
[color.name, color.hex, color.cena_refill, color.cena_spulna]
|
||||||
|
);
|
||||||
|
console.log(`✅ Added: ${color.name} (${color.hex})`);
|
||||||
|
added++;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Error with ${color.name}:`, error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n📊 Summary:`);
|
||||||
|
console.log(` Added: ${added}`);
|
||||||
|
console.log(` Updated: ${updated}`);
|
||||||
|
console.log(` Skipped: ${skipped}`);
|
||||||
|
console.log(` Total: ${missingColors.length}`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ Failed to add colors:', error.message);
|
||||||
|
} finally {
|
||||||
|
await pool.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addMissingColors();
|
||||||
@@ -49,7 +49,7 @@ export const bambuLabColors = {
|
|||||||
"Matte Dark Chocolate": "#4A3729",
|
"Matte Dark Chocolate": "#4A3729",
|
||||||
"Matte Dark Green": "#68724D",
|
"Matte Dark Green": "#68724D",
|
||||||
"Matte Dark Red": "#BB3D43",
|
"Matte Dark Red": "#BB3D43",
|
||||||
"Matte Grass Green": "#7CB342",
|
"Matte Grass Green": "#61C680",
|
||||||
"Matte Ice Blue": "#A3D8E1",
|
"Matte Ice Blue": "#A3D8E1",
|
||||||
"Matte Lemon Yellow": "#F7D959",
|
"Matte Lemon Yellow": "#F7D959",
|
||||||
"Matte Lilac Purple": "#AE96D4",
|
"Matte Lilac Purple": "#AE96D4",
|
||||||
@@ -109,7 +109,12 @@ export const bambuLabColors = {
|
|||||||
// Support Materials
|
// Support Materials
|
||||||
"Natural": "#F5F5DC",
|
"Natural": "#F5F5DC",
|
||||||
"Support White": "#F5F5F5",
|
"Support White": "#F5F5F5",
|
||||||
"Support G": "#90CAF9"
|
"Support G": "#90CAF9",
|
||||||
|
|
||||||
|
// Wood Colors
|
||||||
|
"Ochre Yellow": "#BC8B39",
|
||||||
|
"White Oak": "#D2CCA2",
|
||||||
|
"Clay Brown": "#8E621A"
|
||||||
};
|
};
|
||||||
|
|
||||||
// Colors grouped by finish type for easier selection
|
// Colors grouped by finish type for easier selection
|
||||||
@@ -151,6 +156,9 @@ export const colorsByFinish = {
|
|||||||
],
|
],
|
||||||
"Support": [
|
"Support": [
|
||||||
"Natural", "Support White", "Support G"
|
"Natural", "Support White", "Support G"
|
||||||
|
],
|
||||||
|
"Wood": [
|
||||||
|
"Ochre Yellow", "White Oak", "Clay Brown"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -159,3 +159,26 @@ resource "cloudflare_record" "frontend_www" {
|
|||||||
proxied = true # Enable Cloudflare proxy for SSL and caching
|
proxied = true # Enable Cloudflare proxy for SSL and caching
|
||||||
comment = "CloudFront distribution for frontend (www)"
|
comment = "CloudFront distribution for frontend (www)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Cloudflare Transform Rule to rewrite Host header for CloudFront
|
||||||
|
resource "cloudflare_ruleset" "frontend_host_header_rewrite" {
|
||||||
|
count = var.domain_name != "" && var.cloudflare_api_token != "" ? 1 : 0
|
||||||
|
zone_id = data.cloudflare_zone.domain[0].id
|
||||||
|
name = "Rewrite Host header for CloudFront"
|
||||||
|
kind = "zone"
|
||||||
|
phase = "http_request_late_transform"
|
||||||
|
|
||||||
|
rules {
|
||||||
|
action = "rewrite"
|
||||||
|
expression = "(http.host eq \"${var.domain_name}\" or http.host eq \"www.${var.domain_name}\")"
|
||||||
|
description = "Rewrite Host header to CloudFront domain"
|
||||||
|
|
||||||
|
action_parameters {
|
||||||
|
headers {
|
||||||
|
name = "Host"
|
||||||
|
operation = "set"
|
||||||
|
value = aws_cloudfront_distribution.frontend.domain_name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user