mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 23:19:40 +02:00
Extract feedback, analytics, and AI modules from mana-core-auth into standalone mana-analytics service (Hono + Bun, Port 3064). New service (services/mana-analytics/): - User feedback CRUD with voting - AI-powered feedback title generation via mana-llm - Simplified from DuckDB analytics to pure PostgreSQL - ~550 LOC Removed from mana-core-auth: - feedback/ module (6 files) - analytics/ module (4 files) - ai/ module (3 files) - db/schema/feedback.schema.ts mana-core-auth now contains ONLY pure auth: - Better Auth (JWT, Sessions, 2FA, Passkeys, OIDC, Magic Links) - Organizations/Guilds (membership management) - API Keys, Security, Me (GDPR), Health, Metrics - Ready for Phase 5: Hono rewrite Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
/**
|
|
* mana-analytics — Feedback and analytics service
|
|
*
|
|
* Hono + Bun runtime. Extracted from mana-core-auth.
|
|
* Handles: user feedback, voting, AI-powered title generation.
|
|
*/
|
|
|
|
import { Hono } from 'hono';
|
|
import { cors } from 'hono/cors';
|
|
import { loadConfig } from './config';
|
|
import { getDb } from './db/connection';
|
|
import { errorHandler } from './middleware/error-handler';
|
|
import { jwtAuth } from './middleware/jwt-auth';
|
|
import { FeedbackService } from './services/feedback';
|
|
import { healthRoutes } from './routes/health';
|
|
import { createFeedbackRoutes } from './routes/feedback';
|
|
|
|
const config = loadConfig();
|
|
const db = getDb(config.databaseUrl);
|
|
|
|
const feedbackService = new FeedbackService(db, config.manaLlmUrl);
|
|
|
|
const app = new Hono();
|
|
|
|
app.onError(errorHandler);
|
|
app.use('*', cors({ origin: config.cors.origins, credentials: true }));
|
|
|
|
app.route('/health', healthRoutes);
|
|
|
|
app.use('/api/v1/feedback/*', jwtAuth(config.manaAuthUrl));
|
|
app.route('/api/v1/feedback', createFeedbackRoutes(feedbackService));
|
|
|
|
console.log(`mana-analytics starting on port ${config.port}...`);
|
|
|
|
export default {
|
|
port: config.port,
|
|
fetch: app.fetch,
|
|
};
|