feat: add database and orm
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
import { AuthGuard } from '../common/auth/auth.guard';
|
||||
import { CurrentUser } from '../common/auth/current-user.decorator';
|
||||
import { parseLimit, rawCursorParam } from '../common/dto/pagination-query.dto';
|
||||
import { User } from '../common/store/domain';
|
||||
import { User } from '../common/domain';
|
||||
import { CreateMessageDto } from './dto/create-message.dto';
|
||||
import {
|
||||
MessagePageResponse,
|
||||
@@ -27,22 +27,22 @@ export class MessagesController {
|
||||
|
||||
@Post()
|
||||
@HttpCode(201)
|
||||
create(
|
||||
async create(
|
||||
@Param('chatId') chatId: string,
|
||||
@Body() dto: CreateMessageDto,
|
||||
@CurrentUser() user: User,
|
||||
): MessageResponse {
|
||||
const message = this.messages.create(chatId, user.id, dto.text);
|
||||
): Promise<MessageResponse> {
|
||||
const message = await this.messages.create(chatId, user.id, dto.text);
|
||||
return toMessageResponse(message);
|
||||
}
|
||||
|
||||
@Get()
|
||||
list(
|
||||
async list(
|
||||
@Param('chatId') chatId: string,
|
||||
@CurrentUser() user: User,
|
||||
@Query('limit') limitRaw: unknown,
|
||||
@Query('cursor') cursorRaw: unknown,
|
||||
): MessagePageResponse {
|
||||
): Promise<MessagePageResponse> {
|
||||
const limit = parseLimit(limitRaw);
|
||||
const cursor = rawCursorParam(cursorRaw);
|
||||
return this.messages.list(chatId, user.id, limit, cursor);
|
||||
|
||||
Reference in New Issue
Block a user