From e88597cd20939ecaf7a17b4ca211e556f4c07967 Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Sat, 14 Feb 2026 11:23:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(gifts):=20add=20gift=20code=20?= =?UTF-8?q?creation=20script=20and=20initial=20codes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add create-gift-codes.mjs script for batch gift code generation - Create 10 gift codes with 1000 Mana each for distribution Co-Authored-By: Claude Opus 4.5 --- gift-codes-2026-02-14.txt | 78 ++++++++++++++++++++++ scripts/create-gift-codes.mjs | 121 ++++++++++++++++++++++++++++++++++ 2 files changed, 199 insertions(+) create mode 100644 gift-codes-2026-02-14.txt create mode 100644 scripts/create-gift-codes.mjs diff --git a/gift-codes-2026-02-14.txt b/gift-codes-2026-02-14.txt new file mode 100644 index 000000000..40b12ac2c --- /dev/null +++ b/gift-codes-2026-02-14.txt @@ -0,0 +1,78 @@ +Mana Gift Codes - Created 2026-02-14 +10 codes with 1000 Mana each +============================================================ + +Diese Codes sind LIVE auf Production (auth.mana.how) +Gueltig bis: 2026-05-15 + +============================================================ +GIFT CODES +============================================================ + +1. Code: MANA01 + URL: https://mana.how/g/MANA01 + Mana: 1000 + +2. Code: MANA02 + URL: https://mana.how/g/MANA02 + Mana: 1000 + +3. Code: MANA03 + URL: https://mana.how/g/MANA03 + Mana: 1000 + +4. Code: MANA04 + URL: https://mana.how/g/MANA04 + Mana: 1000 + +5. Code: MANA05 + URL: https://mana.how/g/MANA05 + Mana: 1000 + +6. Code: MANA06 + URL: https://mana.how/g/MANA06 + Mana: 1000 + +7. Code: MANA07 + URL: https://mana.how/g/MANA07 + Mana: 1000 + +8. Code: MANA08 + URL: https://mana.how/g/MANA08 + Mana: 1000 + +9. Code: MANA09 + URL: https://mana.how/g/MANA09 + Mana: 1000 + +10. Code: MANA10 + URL: https://mana.how/g/MANA10 + Mana: 1000 + +============================================================ +Zum Teilen (URLs): + +https://mana.how/g/MANA01 +https://mana.how/g/MANA02 +https://mana.how/g/MANA03 +https://mana.how/g/MANA04 +https://mana.how/g/MANA05 +https://mana.how/g/MANA06 +https://mana.how/g/MANA07 +https://mana.how/g/MANA08 +https://mana.how/g/MANA09 +https://mana.how/g/MANA10 + +============================================================ +Nur die Codes: + +MANA01 +MANA02 +MANA03 +MANA04 +MANA05 +MANA06 +MANA07 +MANA08 +MANA09 +MANA10 diff --git a/scripts/create-gift-codes.mjs b/scripts/create-gift-codes.mjs new file mode 100644 index 000000000..3f466bda6 --- /dev/null +++ b/scripts/create-gift-codes.mjs @@ -0,0 +1,121 @@ +#!/usr/bin/env node + +/** + * Creates multiple gift codes via the mana-core-auth API + * + * Usage: + * node scripts/create-gift-codes.mjs + * + * Requirements: + * - mana-core-auth must be running + * - Valid credentials (uses claude-test@mana.how by default) + */ + +const AUTH_URL = process.env.AUTH_URL || 'http://localhost:3001'; +const EMAIL = process.env.AUTH_EMAIL || 'claude-test@mana.how'; +const PASSWORD = process.env.AUTH_PASSWORD || 'ClaudeTest2024'; + +const NUM_CODES = 10; +const CREDITS_PER_CODE = 1000; + +async function login() { + console.log(`Logging in as ${EMAIL}...`); + + const response = await fetch(`${AUTH_URL}/api/v1/auth/login`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email: EMAIL, password: PASSWORD }), + }); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Login failed: ${response.status} - ${error}`); + } + + const data = await response.json(); + return data.accessToken; +} + +async function createGiftCode(token, credits, message) { + const response = await fetch(`${AUTH_URL}/api/v1/gifts`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, + }, + body: JSON.stringify({ + credits, + type: 'simple', + message: message || `Gift of ${credits} Mana`, + }), + }); + + if (!response.ok) { + const error = await response.text(); + throw new Error(`Failed to create gift code: ${response.status} - ${error}`); + } + + return response.json(); +} + +async function main() { + console.log(`Creating ${NUM_CODES} gift codes with ${CREDITS_PER_CODE} Mana each...\n`); + + const token = await login(); + console.log('Login successful!\n'); + + const codes = []; + + for (let i = 0; i < NUM_CODES; i++) { + try { + const result = await createGiftCode(token, CREDITS_PER_CODE, `Mana Gift #${i + 1}`); + codes.push({ + code: result.code, + url: result.url, + credits: result.totalCredits, + }); + console.log(`✓ Created code ${i + 1}/${NUM_CODES}: ${result.code} (${result.url})`); + } catch (error) { + console.error(`✗ Failed to create code ${i + 1}: ${error.message}`); + } + } + + // Output summary + console.log('\n' + '='.repeat(60)); + console.log(`Successfully created ${codes.length}/${NUM_CODES} codes\n`); + + if (codes.length > 0) { + console.log('GIFT CODES:'); + console.log('-'.repeat(60)); + codes.forEach((c, i) => { + console.log(`${i + 1}. ${c.code} → ${c.url} (${c.credits} Mana)`); + }); + console.log('-'.repeat(60)); + + // Also write to file + const fs = await import('fs'); + const date = new Date().toISOString().split('T')[0]; + const filename = `gift-codes-${date}.txt`; + + let fileContent = `Mana Gift Codes - Created ${new Date().toISOString()}\n`; + fileContent += `${codes.length} codes with ${CREDITS_PER_CODE} Mana each\n`; + fileContent += '='.repeat(60) + '\n\n'; + + codes.forEach((c, i) => { + fileContent += `${i + 1}. Code: ${c.code}\n`; + fileContent += ` URL: ${c.url}\n`; + fileContent += ` Mana: ${c.credits}\n\n`; + }); + + fileContent += '='.repeat(60) + '\n'; + fileContent += 'Simple list for sharing:\n\n'; + codes.forEach((c) => { + fileContent += `${c.url}\n`; + }); + + fs.writeFileSync(filename, fileContent); + console.log(`\nSaved to: ${filename}`); + } +} + +main().catch(console.error);