fase(17): licensing module with RSA validation

This commit is contained in:
debian
2026-03-08 05:20:54 -04:00
parent 1f1678af17
commit 5a28270dc9
45 changed files with 1789 additions and 48 deletions

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LicensingController = void 0;
const express_1 = require("express");
const Result_1 = require("../../../../shared/domain/Result");
class LicensingController {
constructor(licenseService) {
this.licenseService = licenseService;
this.router = (0, express_1.Router)();
this.registerRoutes();
}
registerRoutes() {
this.router.get('/status', this.getStatus.bind(this));
this.router.post('/activate', this.activate.bind(this));
}
getStatus(_req, res) {
res.json(this.licenseService.getStatus());
}
async activate(req, res) {
const { licenseKey } = req.body;
if (!licenseKey || typeof licenseKey !== 'string') {
res.status(400).json({ error: 'licenseKey is required' });
return;
}
const result = await this.licenseService.activate(licenseKey.trim());
if ((0, Result_1.isErr)(result)) {
res.status(422).json({ error: result.error });
return;
}
res.json({
message: 'License activated successfully',
license: this.licenseService.getStatus(),
});
}
}
exports.LicensingController = LicensingController;