diff --git a/backend/src/services/nameGenerator.js b/backend/src/services/nameGenerator.js new file mode 100644 index 0000000..931a80c --- /dev/null +++ b/backend/src/services/nameGenerator.js @@ -0,0 +1,37 @@ +import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) +const namesPath = path.join(__dirname, '../../data/names.txt') + +let allNames = [] + +function loadNames() { + try { + const content = fs.readFileSync(namesPath, 'utf-8') + allNames = content + .split('\n') + .map(name => name.trim()) + .filter(name => name.length > 0) + } catch (error) { + console.error('Error loading names:', error) + allNames = ['Alex', 'Jordan', 'Casey', 'Morgan', 'Riley'] // Fallback + } +} + +// Load names on module import +loadNames() + +export function getRandomNames(count) { + if (count > allNames.length) { + throw new Error(`Cannot get ${count} unique names. Only ${allNames.length} available.`) + } + + const shuffled = [...allNames].sort(() => Math.random() - 0.5) + return shuffled.slice(0, count) +} + +export function getRandomName() { + return allNames[Math.floor(Math.random() * allNames.length)] +} diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 24fc473..1392c42 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9,6 +9,8 @@ "version": "0.0.0", "dependencies": { "@vueuse/core": "^13.9.0", + "highlight.js": "^11.11.1", + "marked": "^16.4.1", "mermaid": "^11.12.0", "pinia": "^3.0.3", "radix-vue": "^1.9.17", @@ -2284,6 +2286,15 @@ "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==", "license": "MIT" }, + "node_modules/highlight.js": { + "version": "11.11.1", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.11.1.tgz", + "integrity": "sha512-Xwwo44whKBVCYoliBQwaPvtd/2tYFkRQtXDWj1nackaV2JPXx3L0+Jvd8/qCJ2p+ML0/XVkJ2q+Mr+UVdpJK5w==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/hookable": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", diff --git a/frontend/package.json b/frontend/package.json index 1dc42ad..61a853f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,6 +10,8 @@ }, "dependencies": { "@vueuse/core": "^13.9.0", + "highlight.js": "^11.11.1", + "marked": "^16.4.1", "mermaid": "^11.12.0", "pinia": "^3.0.3", "radix-vue": "^1.9.17", diff --git a/frontend/src/components/DocumentViewer.vue b/frontend/src/components/DocumentViewer.vue index 369dbd9..92284b5 100644 --- a/frontend/src/components/DocumentViewer.vue +++ b/frontend/src/components/DocumentViewer.vue @@ -1,5 +1,7 @@