@corvina/device-example
Version:
Corvina Device Example based on @corvina/device-client
76 lines • 3.23 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var Config_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const common_1 = require("@nestjs/common");
const device_client_1 = require("@corvina/device-client");
const swagger_1 = require("@nestjs/swagger");
const deviceconfig_dto_1 = require("./dto/deviceconfig.dto");
const licensedata_dto_1 = require("./dto/licensedata.dto");
let Config = Config_1 = class Config {
deviceService;
l = new common_1.Logger(Config_1.name);
constructor(deviceService) {
this.deviceService = deviceService;
}
config(newConfig) {
this.l.log("apply new config");
this.deviceService.reinit(newConfig);
return new deviceconfig_dto_1.DeviceConfigDTO(this.deviceService.getDeviceConfig());
}
get() {
const config = this.deviceService.getAppliedConfig();
return config;
}
getLicenseData() {
return this.deviceService.getLicenseData();
}
};
exports.Config = Config;
__decorate([
(0, swagger_1.ApiOperation)({
summary: "Applied a new device configuration",
}),
(0, common_1.Post)("/config"),
__param(0, (0, common_1.Body)("newConfig")),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", deviceconfig_dto_1.DeviceConfigDTO)
], Config.prototype, "config", null);
__decorate([
(0, swagger_1.ApiOperation)({
summary: "Get current applied device configuration",
}),
(0, common_1.Get)("/config"),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Object)
], Config.prototype, "get", null);
__decorate([
(0, swagger_1.ApiOperation)({
summary: "Get current device license data",
}),
(0, common_1.Get)("/licenseData"),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", licensedata_dto_1.LicenseDataDTO)
], Config.prototype, "getLicenseData", null);
exports.Config = Config = Config_1 = __decorate([
(0, swagger_1.ApiTags)("device"),
(0, common_1.Controller)("/device"),
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [device_client_1.DeviceService])
], Config);
//# sourceMappingURL=config.controller.js.map