176 lines
7.3 KiB
JavaScript
176 lines
7.3 KiB
JavaScript
"use strict";
|
|
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); }
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.AdminController = void 0;
|
|
const common_1 = require("@nestjs/common");
|
|
const gift_service_1 = require("../gift/services/gift.service");
|
|
const guest_service_1 = require("../guest/services/guest.service");
|
|
const todo_service_1 = require("../todo/services/todo.service");
|
|
const module_registry_service_1 = require("../core/services/module-registry.service");
|
|
const DEFAULT_TENANT = process.env.DEFAULT_TENANT_ID ?? 'default';
|
|
let AdminController = class AdminController {
|
|
constructor(moduleRegistry, guestService, giftService, todoService) {
|
|
this.moduleRegistry = moduleRegistry;
|
|
this.guestService = guestService;
|
|
this.giftService = giftService;
|
|
this.todoService = todoService;
|
|
}
|
|
getModules() {
|
|
return this.moduleRegistry.getModules();
|
|
}
|
|
getTenantId(tenantId) {
|
|
return tenantId ?? DEFAULT_TENANT;
|
|
}
|
|
// Guests
|
|
listGuests(tenantId) {
|
|
return this.guestService.listGuests(this.getTenantId(tenantId));
|
|
}
|
|
createGuest(tenantId, body) {
|
|
return this.guestService.createGuest(this.getTenantId(tenantId), body);
|
|
}
|
|
updateGuestRsvp(tenantId, id, body) {
|
|
return this.guestService.updateRsvp(this.getTenantId(tenantId), id, body);
|
|
}
|
|
// Todos
|
|
listTodos(tenantId) {
|
|
return this.todoService.listTodos(this.getTenantId(tenantId));
|
|
}
|
|
createTodo(tenantId, body) {
|
|
return this.todoService.createTodo(this.getTenantId(tenantId), body);
|
|
}
|
|
completeTodo(tenantId, id) {
|
|
return this.todoService.markComplete(this.getTenantId(tenantId), id);
|
|
}
|
|
// Gifts
|
|
listGifts(tenantId) {
|
|
return this.giftService.listGifts(this.getTenantId(tenantId));
|
|
}
|
|
createGift(tenantId, body) {
|
|
return this.giftService.createGift(this.getTenantId(tenantId), body);
|
|
}
|
|
getGift(tenantId, id) {
|
|
return this.giftService.getGiftById(this.getTenantId(tenantId), id);
|
|
}
|
|
createContribution(tenantId, id, body) {
|
|
return this.giftService.createContribution(this.getTenantId(tenantId), {
|
|
...body,
|
|
giftId: id,
|
|
});
|
|
}
|
|
listContributions(tenantId, id) {
|
|
return this.giftService.listContributions(this.getTenantId(tenantId), id);
|
|
}
|
|
};
|
|
exports.AdminController = AdminController;
|
|
__decorate([
|
|
(0, common_1.Get)('modules'),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "getModules", null);
|
|
__decorate([
|
|
(0, common_1.Get)('guest'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "listGuests", null);
|
|
__decorate([
|
|
(0, common_1.Post)('guest'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "createGuest", null);
|
|
__decorate([
|
|
(0, common_1.Patch)('guest/:id/rsvp'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Param)('id')),
|
|
__param(2, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "updateGuestRsvp", null);
|
|
__decorate([
|
|
(0, common_1.Get)('todo'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "listTodos", null);
|
|
__decorate([
|
|
(0, common_1.Post)('todo'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "createTodo", null);
|
|
__decorate([
|
|
(0, common_1.Patch)('todo/:id/complete'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Param)('id')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "completeTodo", null);
|
|
__decorate([
|
|
(0, common_1.Get)('gift'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "listGifts", null);
|
|
__decorate([
|
|
(0, common_1.Post)('gift'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "createGift", null);
|
|
__decorate([
|
|
(0, common_1.Get)('gift/:id'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Param)('id')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "getGift", null);
|
|
__decorate([
|
|
(0, common_1.Post)('gift/:id/contribution'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Param)('id')),
|
|
__param(2, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "createContribution", null);
|
|
__decorate([
|
|
(0, common_1.Get)('gift/:id/contributions'),
|
|
__param(0, (0, common_1.Query)('tenantId')),
|
|
__param(1, (0, common_1.Param)('id')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String]),
|
|
__metadata("design:returntype", void 0)
|
|
], AdminController.prototype, "listContributions", null);
|
|
exports.AdminController = AdminController = __decorate([
|
|
(0, common_1.Controller)('admin'),
|
|
__metadata("design:paramtypes", [module_registry_service_1.ModuleRegistryService,
|
|
guest_service_1.GuestService,
|
|
gift_service_1.GiftService,
|
|
todo_service_1.TodoService])
|
|
], AdminController);
|