74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
|
|
function _ts_decorate(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;
|
||
|
|
}
|
||
|
|
function _ts_metadata(k, v) {
|
||
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||
|
|
}
|
||
|
|
function _ts_param(paramIndex, decorator) {
|
||
|
|
return function(target, key) {
|
||
|
|
decorator(target, key, paramIndex);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post } from '@nestjs/common';
|
||
|
|
import { SessionService } from './session.service';
|
||
|
|
import { CreateSessionDto } from './dto/session.dto';
|
||
|
|
export class SessionController {
|
||
|
|
constructor(sessionService){
|
||
|
|
this.sessionService = sessionService;
|
||
|
|
}
|
||
|
|
async createSession(dto) {
|
||
|
|
const session = await this.sessionService.createSession({
|
||
|
|
personaId: dto.persona_id,
|
||
|
|
userId: dto.user_id
|
||
|
|
});
|
||
|
|
return {
|
||
|
|
session_id: session.id
|
||
|
|
};
|
||
|
|
}
|
||
|
|
async getHistory(sessionId) {
|
||
|
|
return this.sessionService.getHistory(sessionId);
|
||
|
|
}
|
||
|
|
async deleteSession(sessionId) {
|
||
|
|
await this.sessionService.deleteSession(sessionId);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
_ts_decorate([
|
||
|
|
Post(),
|
||
|
|
_ts_param(0, Body()),
|
||
|
|
_ts_metadata("design:type", Function),
|
||
|
|
_ts_metadata("design:paramtypes", [
|
||
|
|
typeof CreateSessionDto === "undefined" ? Object : CreateSessionDto
|
||
|
|
]),
|
||
|
|
_ts_metadata("design:returntype", Promise)
|
||
|
|
], SessionController.prototype, "createSession", null);
|
||
|
|
_ts_decorate([
|
||
|
|
Get(':id/history'),
|
||
|
|
_ts_param(0, Param('id')),
|
||
|
|
_ts_metadata("design:type", Function),
|
||
|
|
_ts_metadata("design:paramtypes", [
|
||
|
|
String
|
||
|
|
]),
|
||
|
|
_ts_metadata("design:returntype", Promise)
|
||
|
|
], SessionController.prototype, "getHistory", null);
|
||
|
|
_ts_decorate([
|
||
|
|
Delete(':id'),
|
||
|
|
HttpCode(HttpStatus.NO_CONTENT),
|
||
|
|
_ts_param(0, Param('id')),
|
||
|
|
_ts_metadata("design:type", Function),
|
||
|
|
_ts_metadata("design:paramtypes", [
|
||
|
|
String
|
||
|
|
]),
|
||
|
|
_ts_metadata("design:returntype", Promise)
|
||
|
|
], SessionController.prototype, "deleteSession", null);
|
||
|
|
SessionController = _ts_decorate([
|
||
|
|
Controller('session'),
|
||
|
|
_ts_metadata("design:type", Function),
|
||
|
|
_ts_metadata("design:paramtypes", [
|
||
|
|
typeof SessionService === "undefined" ? Object : SessionService
|
||
|
|
])
|
||
|
|
], SessionController);
|
||
|
|
|
||
|
|
//# sourceMappingURL=session.controller.js.map
|