Spaces:
Sleeping
Sleeping
feat: complete Ever-Brain engine, MCP server, CLI evb mcp command, Dockerfile and release workflow
61b1da1 Download packages/api/src/app.ts from projectsorg/ever-brain: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/api/src/app.ts
- Command line
-
hf download hf://spaces/projectsorg/ever-brain/packages/api/src/app.ts
-
curl -L -o app.ts https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/api/src/app.ts
1.5 kB
| import { Hono } from 'hono'; | |
| import { cors } from 'hono/cors'; | |
| import { healthRouter } from './routes/health.js'; | |
| import { reposRouter } from './routes/repos.js'; | |
| export const app = new Hono(); | |
| // Enable CORS for all incoming agent/developer requests | |
| app.use( | |
| '*', | |
| cors({ | |
| origin: '*', | |
| allowMethods: ['GET', 'HEAD', 'OPTIONS'], | |
| allowHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'], | |
| exposeHeaders: ['X-Ever-Brain-Path', 'X-Ever-Brain-Branch'], | |
| }) | |
| ); | |
| // Route mounts | |
| app.route('/health', healthRouter); | |
| app.route('/repos', reposRouter); | |
| // Backward compatibility mount: /projects/:owner/:repo -> /repos/:owner/:repo | |
| app.route('/projects', reposRouter); | |
| // Root route | |
| app.get('/', (c) => { | |
| return c.json({ | |
| name: 'Ever-Brain API', | |
| version: '1.0.0', | |
| description: 'Ever-Brain Stateless Content Access Layer', | |
| endpoints: [ | |
| 'GET /health', | |
| 'GET /repos/:owner/:repo', | |
| 'GET /repos/:owner/:repo/files', | |
| 'GET /repos/:owner/:repo/file/*path', | |
| 'GET /repos/:owner/:repo/search?q=:query', | |
| ], | |
| }); | |
| }); | |
| // 404 Handler | |
| app.notFound((c) => { | |
| return c.json( | |
| { | |
| error: `Route not found: ${c.req.method} ${c.req.path}`, | |
| code: 'NOT_FOUND', | |
| }, | |
| 404 | |
| ); | |
| }); | |
| // Global Error Handler | |
| app.onError((err, c) => { | |
| console.error('[Ever-Brain API Unhandled Error]', err); | |
| return c.json( | |
| { | |
| error: err.message || 'Internal server error', | |
| code: 'INTERNAL_SERVER_ERROR', | |
| }, | |
| 500 | |
| ); | |
| }); | |