donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
54 lines • 1.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnvDataApi = void 0;
const v4_1 = require("zod/v4");
/**
* API controller for environment data management endpoints.
*/
class EnvDataApi {
constructor(environmentDataManager) {
this.environmentDataManager = environmentDataManager;
}
/**
* Get all environment data.
*/
async getEnvironmentData(_req, res) {
const data = await this.environmentDataManager.getEnvironmentData();
res.json(data);
}
/**
* Get a specific environment datum by key.
*/
async getEnvironmentDatum(req, res) {
const key = String(req.params.key);
const value = await this.environmentDataManager.getEnvironmentDatum(key);
if (value === undefined) {
res.status(404).json({ error: `Environment datum '${key}' not found` });
return;
}
res.json({ key, value });
}
/**
* Create or update an environment datum.
*/
async setEnvironmentDatum(req, res) {
const key = String(req.params.key);
const parsedBody = v4_1.z
.object({
value: v4_1.z.string(),
})
.parse(req.body);
await this.environmentDataManager.setEnvironmentDatum(key, parsedBody.value);
res.status(201).json({ key: key, value: parsedBody.value });
}
/**
* Delete an environment datum by key.
*/
async deleteEnvironmentDatum(req, res) {
const key = String(req.params.key);
await this.environmentDataManager.deleteEnvironmentDatum(key);
res.sendStatus(200);
}
}
exports.EnvDataApi = EnvDataApi;
//# sourceMappingURL=EnvDataApi.js.map