- Added bestiaryRoutes.js to handle API endpoints for fetching enemies, full bestiary data, and statistics. - Implemented caching mechanism for bestiary data with a 5-minute expiration. - Created transformation functions for bestiary entries to standardize data format for the dice roller. - Added admin-only endpoint to force reload bestiary data with GM authentication. chore: Create scripts for analyzing and cleaning bestiary data - Developed analyze-bestiary-quality.js to review data quality and identify duplicates or inconsistencies. - Implemented clean-bestiary-fields.js to extract and clean specific fields from bestiary entries, reducing text duplication. - Created clean-corrupted-bestiary.js to remove corrupted entries based on defined patterns. - Generated a comprehensive database-cleanup-report.md summarizing the cleaning process and results. build: Add fast build script for streamlined deployment - Introduced fast-build.sh to facilitate quick builds and PM2 reloads without reinstalling dependencies. test: Add GM authentication logic test - Created test-gm-auth.js to verify the correctness of GM authentication logic with various test cases.
23 lines
742 B
JavaScript
23 lines
742 B
JavaScript
// Quick test to verify GM authentication logic
|
|
const testGMAuth = () => {
|
|
console.log('Testing GM Authentication Logic:');
|
|
|
|
// Test cases
|
|
const testCases = [
|
|
{ authedPlayer: 'gm', expected: true },
|
|
{ authedPlayer: 'anders', expected: false },
|
|
{ authedPlayer: 'andreas', expected: false },
|
|
{ authedPlayer: '', expected: false },
|
|
{ authedPlayer: null, expected: false },
|
|
{ authedPlayer: undefined, expected: false },
|
|
];
|
|
|
|
testCases.forEach(({ authedPlayer, expected }) => {
|
|
const isGM = authedPlayer === 'gm';
|
|
const result = isGM === expected ? '✅ PASS' : '❌ FAIL';
|
|
console.log(`${result} authedPlayer: '${authedPlayer}' → isGM: ${isGM} (expected: ${expected})`);
|
|
});
|
|
};
|
|
|
|
testGMAuth();
|