bugfixes; research subproc; higher sandbox limits

This commit is contained in:
2026-04-16 18:11:26 -04:00
parent f80c943dc3
commit 3153e89d4f
54 changed files with 1947 additions and 498 deletions

View File

@@ -0,0 +1,35 @@
import type { FastifyInstance } from 'fastify';
import type { ContainerManager } from '../k8s/container-manager.js';
import type { UserService } from '../db/user-service.js';
import type { LicenseTier } from '../types/user.js';
const VALID_TIERS: LicenseTier[] = ['free', 'pro', 'enterprise'];
export class AdminRoutes {
private containerManager: ContainerManager;
private userService: UserService;
constructor(containerManager: ContainerManager, userService: UserService) {
this.containerManager = containerManager;
this.userService = userService;
}
register(app: FastifyInstance): void {
app.post<{ Params: { userId: string }; Body: { tier: string } }>(
'/admin/users/:userId/set-tier',
async (req, reply) => {
const { userId } = req.params;
const { tier } = req.body;
if (!VALID_TIERS.includes(tier as LicenseTier)) {
return reply.code(400).send({ error: `Invalid tier. Must be one of: ${VALID_TIERS.join(', ')}` });
}
const license = await this.containerManager.applyLicenseTier(userId, tier as LicenseTier);
return { userId, tier, license };
}
);
app.post('/admin/migrate-licenses', async () => {
return await this.userService.migrateAllLicenses();
});
}
}