mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-28 00:57:43 +02:00
refactor: consolidate codebase — remove archived code, deduplicate packages, standardize middleware
- Delete 17 server-archived/ directories (consolidated into apps/api/) - Delete apps-archived/ (clock, wisekeep) and services-archived/ (it-landing, ollama-metrics-proxy) - Fix type safety: replace all `any` casts in cross-app-queries.ts with proper Local* types - Remove duplicate shared-auth-stores package (identical copy of shared-auth-ui/stores/) - Remove duplicate theme store from shared-stores (canonical version in shared-theme) - Migrate memoro-server rate-limiter to shared-hono/rateLimitMiddleware - Migrate uload-server JWT auth + error handler to shared-hono (authMiddleware, errorHandler) - Migrate arcade-server error handling to shared-hono - Merge shared-profile-ui and shared-app-onboarding into shared-ui - Unify /clock route into /times/clock, remove redirect stubs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7ee57b7afd
commit
d8ce4eaf34
309 changed files with 172 additions and 21667 deletions
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"name": "@mukke/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch src/index.ts",
|
||||
"start": "bun run src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@manacore/shared-hono": "workspace:*",
|
||||
"@manacore/shared-storage": "workspace:*",
|
||||
"hono": "^4.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/**
|
||||
* Mukke Hono Server — Audio upload, metadata, presigned URLs
|
||||
*
|
||||
* CRUD for songs/playlists/projects handled by mana-sync.
|
||||
* This server handles S3 operations and metadata extraction.
|
||||
*/
|
||||
|
||||
import { Hono } from 'hono';
|
||||
import { cors } from 'hono/cors';
|
||||
import { authMiddleware, healthRoute, errorHandler, notFoundHandler } from '@manacore/shared-hono';
|
||||
|
||||
const PORT = parseInt(process.env.PORT || '3010', 10);
|
||||
const CORS_ORIGINS = (process.env.CORS_ORIGINS || 'http://localhost:5180').split(',');
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
app.onError(errorHandler);
|
||||
app.notFound(notFoundHandler);
|
||||
app.use('*', cors({ origin: CORS_ORIGINS, credentials: true }));
|
||||
app.route('/health', healthRoute('mukke-server'));
|
||||
app.use('/api/*', authMiddleware());
|
||||
|
||||
// ─── Song Upload (server-only: S3 presigned URL) ────────────
|
||||
|
||||
app.post('/api/v1/songs/upload', async (c) => {
|
||||
const userId = c.get('userId');
|
||||
const { filename } = await c.req.json();
|
||||
|
||||
if (!filename) return c.json({ error: 'filename required' }, 400);
|
||||
|
||||
const songId = crypto.randomUUID();
|
||||
const key = `users/${userId}/songs/${songId}/${filename}`;
|
||||
|
||||
// Generate presigned upload URL
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const uploadUrl = await storage.getUploadUrl(key, { expiresIn: 3600 });
|
||||
|
||||
return c.json({
|
||||
song: { id: songId, title: filename.replace(/\.[^/.]+$/, ''), storagePath: key },
|
||||
uploadUrl,
|
||||
});
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Failed to generate upload URL' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Download URL (server-only: S3 presigned URL) ────────────
|
||||
|
||||
app.get('/api/v1/songs/:id/download-url', async (c) => {
|
||||
const { storagePath } = c.req.query();
|
||||
if (!storagePath) return c.json({ error: 'storagePath required' }, 400);
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const url = await storage.getDownloadUrl(storagePath, { expiresIn: 3600 });
|
||||
return c.json({ url });
|
||||
} catch (_err) {
|
||||
return c.json({ error: 'Failed to generate download URL' }, 500);
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Cover Art URL (server-only: S3 presigned URL) ───────────
|
||||
|
||||
app.get('/api/v1/songs/:id/cover-url', async (c) => {
|
||||
const { coverArtPath } = c.req.query();
|
||||
if (!coverArtPath) return c.json({ url: null });
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const url = await storage.getDownloadUrl(coverArtPath, { expiresIn: 3600 });
|
||||
return c.json({ url });
|
||||
} catch (_err) {
|
||||
return c.json({ url: null });
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Batch Cover URLs ────────────────────────────────────────
|
||||
|
||||
app.post('/api/v1/library/cover-urls', async (c) => {
|
||||
const { paths } = await c.req.json();
|
||||
if (!paths?.length) return c.json({ urls: {} });
|
||||
|
||||
try {
|
||||
const { createMukkeStorage } = await import('@manacore/shared-storage');
|
||||
const storage = createMukkeStorage();
|
||||
const urls: Record<string, string> = {};
|
||||
|
||||
for (const path of paths.slice(0, 50)) {
|
||||
try {
|
||||
urls[path] = await storage.getDownloadUrl(path, { expiresIn: 3600 });
|
||||
} catch {
|
||||
// Skip failed URLs
|
||||
}
|
||||
}
|
||||
|
||||
return c.json({ urls });
|
||||
} catch (_err) {
|
||||
return c.json({ urls: {} });
|
||||
}
|
||||
});
|
||||
|
||||
export default { port: PORT, fetch: app.fetch };
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue