chore: initial commit for phase03

This commit is contained in:
hibna
2026-02-21 13:37:46 +03:00
parent 8eb7c90958
commit d0c20581b6
12 changed files with 1175 additions and 0 deletions
+15
View File
@@ -4,6 +4,10 @@ import cookie from '@fastify/cookie';
import dbPlugin from './plugins/db.js';
import authPlugin from './plugins/auth.js';
import authRoutes from './routes/auth/index.js';
import organizationRoutes from './routes/organizations/index.js';
import nodeRoutes from './routes/nodes/index.js';
import serverRoutes from './routes/servers/index.js';
import adminRoutes from './routes/admin/index.js';
import { AppError } from './lib/errors.js';
const app = Fastify({
@@ -56,6 +60,17 @@ app.get('/api/health', async () => {
});
await app.register(authRoutes, { prefix: '/api/auth' });
await app.register(organizationRoutes, { prefix: '/api/organizations' });
await app.register(adminRoutes, { prefix: '/api/admin' });
// Nested org routes: nodes and servers are scoped to an org
await app.register(
async (orgScope) => {
await orgScope.register(nodeRoutes, { prefix: '/nodes' });
await orgScope.register(serverRoutes, { prefix: '/servers' });
},
{ prefix: '/api/organizations/:orgId' },
);
// Start
const PORT = Number(process.env.PORT) || 3000;