mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 15:41:09 +02:00
✨ feat(gifts): add gift code creation script and initial codes
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
4a26926fae
commit
e88597cd20
2 changed files with 199 additions and 0 deletions
78
gift-codes-2026-02-14.txt
Normal file
78
gift-codes-2026-02-14.txt
Normal file
|
|
@ -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
|
||||
121
scripts/create-gift-codes.mjs
Normal file
121
scripts/create-gift-codes.mjs
Normal file
|
|
@ -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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue