Initial: Fastify API + DB schema + collab setup

- Fastify API on :3000 (tasks, groups, auth, connectors)
- PostgreSQL schema: users, tasks, task_groups, goals, connectors
- 8 default task groups
- JWT auth (register/login/me)
- API Bridge framework with webhooks
- CLAUDE.md + polling scripts
- Collab worker integration

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude CLI Agent
2026-03-29 09:57:56 +00:00
commit 9d075455e3
13 changed files with 2430 additions and 0 deletions

41
api/src/index.js Normal file
View File

@@ -0,0 +1,41 @@
// Task Team — API Server — 2026-03-29
require('dotenv').config();
const Fastify = require('fastify');
const cors = require('@fastify/cors');
const jwt = require('@fastify/jwt');
const { Pool } = require('pg');
const app = Fastify({ logger: true });
// Database pool
const pool = new Pool({
connectionString: process.env.DATABASE_URL || 'postgresql://taskteam:TaskTeam2026!@10.10.10.10:5432/taskteam'
});
// Plugins
app.register(cors, { origin: true });
app.register(jwt, { secret: process.env.JWT_SECRET || 'taskteam-jwt-secret-2026' });
// Decorate with db
app.decorate('db', pool);
// Health check
app.get('/health', async () => ({ status: 'ok', timestamp: new Date().toISOString() }));
// Register routes
app.register(require('./routes/tasks'), { prefix: '/api/v1' });
app.register(require('./routes/groups'), { prefix: '/api/v1' });
app.register(require('./routes/auth'), { prefix: '/api/v1' });
app.register(require('./routes/connectors'), { prefix: '/api/v1' });
// Start
const start = async () => {
try {
await app.listen({ port: process.env.PORT || 3000, host: '0.0.0.0' });
console.log('Task Team API listening on port ' + (process.env.PORT || 3000));
} catch (err) {
app.log.error(err);
process.exit(1);
}
};
start();