merge hugo now have a basic functional chat with rooms
This commit is contained in:
106
README.md
106
README.md
@@ -1,5 +1,4 @@
|
||||
- CONFLICT srcs/requirements/svelte/api_front/public/build/bundle.js
|
||||
- CONFLICT srcs/requirements/svelte/api_front/public/build/bundle.js.map
|
||||
CONFLICT srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts
|
||||
|
||||
|
||||
### Pour lancer le docker :
|
||||
@@ -132,3 +131,106 @@
|
||||
- [docker](https://github.com/docker/docker-install)
|
||||
|
||||
|
||||
|
||||
---
|
||||
## http status :
|
||||
|
||||
```
|
||||
- '100': 'CONTINUE',
|
||||
- '101': 'SWITCHING_PROTOCOLS',
|
||||
- '102': 'PROCESSING',
|
||||
- '103': 'EARLYHINTS',
|
||||
- '200': 'OK',
|
||||
- '201': 'CREATED',
|
||||
- '202': 'ACCEPTED',
|
||||
- '203': 'NON_AUTHORITATIVE_INFORMATION',
|
||||
- '204': 'NO_CONTENT',
|
||||
- '205': 'RESET_CONTENT',
|
||||
- '206': 'PARTIAL_CONTENT',
|
||||
- '300': 'AMBIGUOUS',
|
||||
- '301': 'MOVED_PERMANENTLY',
|
||||
- '302': 'FOUND',
|
||||
- '303': 'SEE_OTHER',
|
||||
- '304': 'NOT_MODIFIED',
|
||||
- '307': 'TEMPORARY_REDIRECT',
|
||||
- '308': 'PERMANENT_REDIRECT',
|
||||
- '400': 'BAD_REQUEST',
|
||||
- '401': 'UNAUTHORIZED',
|
||||
- '402': 'PAYMENT_REQUIRED',
|
||||
- '403': 'FORBIDDEN',
|
||||
- '404': 'NOT_FOUND',
|
||||
- '405': 'METHOD_NOT_ALLOWED',
|
||||
- '406': 'NOT_ACCEPTABLE',
|
||||
- '407': 'PROXY_AUTHENTICATION_REQUIRED',
|
||||
- '408': 'REQUEST_TIMEOUT',
|
||||
- '409': 'CONFLICT',
|
||||
- '410': 'GONE',
|
||||
- '411': 'LENGTH_REQUIRED',
|
||||
- '412': 'PRECONDITION_FAILED',
|
||||
- '413': 'PAYLOAD_TOO_LARGE',
|
||||
- '414': 'URI_TOO_LONG',
|
||||
- '415': 'UNSUPPORTED_MEDIA_TYPE',
|
||||
- '416': 'REQUESTED_RANGE_NOT_SATISFIABLE',
|
||||
- '417': 'EXPECTATION_FAILED',
|
||||
- '418': 'I_AM_A_TEAPOT',
|
||||
- '421': 'MISDIRECTED',
|
||||
- '422': 'UNPROCESSABLE_ENTITY',
|
||||
- '424': 'FAILED_DEPENDENCY',
|
||||
- '428': 'PRECONDITION_REQUIRED',
|
||||
- '429': 'TOO_MANY_REQUESTS',
|
||||
- '500': 'INTERNAL_SERVER_ERROR',
|
||||
- '501': 'NOT_IMPLEMENTED',
|
||||
- '502': 'BAD_GATEWAY',
|
||||
- '503': 'SERVICE_UNAVAILABLE',
|
||||
- '504': 'GATEWAY_TIMEOUT',
|
||||
- '505': 'HTTP_VERSION_NOT_SUPPORTED',
|
||||
- CONTINUE: 100,
|
||||
- SWITCHING_PROTOCOLS: 101,
|
||||
- PROCESSING: 102,
|
||||
- EARLYHINTS: 103,
|
||||
- OK: 200,
|
||||
- CREATED: 201,
|
||||
- ACCEPTED: 202,
|
||||
- NON_AUTHORITATIVE_INFORMATION: 203,
|
||||
- NO_CONTENT: 204,
|
||||
- RESET_CONTENT: 205,
|
||||
- PARTIAL_CONTENT: 206,
|
||||
- AMBIGUOUS: 300,
|
||||
- MOVED_PERMANENTLY: 301,
|
||||
- FOUND: 302,
|
||||
- SEE_OTHER: 303,
|
||||
- NOT_MODIFIED: 304,
|
||||
- TEMPORARY_REDIRECT: 307,
|
||||
- PERMANENT_REDIRECT: 308,
|
||||
- BAD_REQUEST: 400,
|
||||
- UNAUTHORIZED: 401,
|
||||
- PAYMENT_REQUIRED: 402,
|
||||
- FORBIDDEN: 403,
|
||||
- NOT_FOUND: 404,
|
||||
- METHOD_NOT_ALLOWED: 405,
|
||||
- NOT_ACCEPTABLE: 406,
|
||||
- PROXY_AUTHENTICATION_REQUIRED: 407,
|
||||
- REQUEST_TIMEOUT: 408,
|
||||
- CONFLICT: 409,
|
||||
- GONE: 410,
|
||||
- LENGTH_REQUIRED: 411,
|
||||
- PRECONDITION_FAILED: 412,
|
||||
- PAYLOAD_TOO_LARGE: 413,
|
||||
- URI_TOO_LONG: 414,
|
||||
- UNSUPPORTED_MEDIA_TYPE: 415,
|
||||
- REQUESTED_RANGE_NOT_SATISFIABLE: 416,
|
||||
- EXPECTATION_FAILED: 417,
|
||||
- I_AM_A_TEAPOT: 418,
|
||||
- MISDIRECTED: 421,
|
||||
- UNPROCESSABLE_ENTITY: 422,
|
||||
- FAILED_DEPENDENCY: 424,
|
||||
- PRECONDITION_REQUIRED: 428,
|
||||
- TOO_MANY_REQUESTS: 429,
|
||||
- INTERNAL_SERVER_ERROR: 500,
|
||||
- NOT_IMPLEMENTED: 501,
|
||||
- BAD_GATEWAY: 502,
|
||||
- SERVICE_UNAVAILABLE: 503,
|
||||
- GATEWAY_TIMEOUT: 504,
|
||||
- HTTP_VERSION_NOT_SUPPORTED: 505
|
||||
```
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { AuthenticationModule } from './auth/42/authentication.module';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { GameModule } from './game/game.module';
|
||||
import { ChatGateway } from './chat/chat.gateway';
|
||||
import { ChatModule } from './chat/chat.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -30,12 +31,10 @@ import { ChatGateway } from './chat/chat.gateway';
|
||||
//avec une classe pour le module
|
||||
synchronize: true,
|
||||
}),
|
||||
ChatModule,
|
||||
// GameModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [
|
||||
AppService,
|
||||
ChatGateway,
|
||||
],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
105
srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts
Normal file
105
srcs/requirements/nestjs/api_back/src/chat/chat.controller.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import { Controller, UseGuards, HttpException, HttpStatus, Get, Post, Body, Req, Res } from '@nestjs/common';
|
||||
import { AuthenticateGuard, TwoFactorGuard } from 'src/auth/42/guards/42guards';
|
||||
import { ConnectedSocket } from '@nestjs/websockets';
|
||||
import { ChatService } from './chat.service';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { PartialUsersDto } from 'src/users/dto/partial-users.dto';
|
||||
import { createRoomDto } from './dto/createRoom.dto';
|
||||
import { joinRoomDto } from './dto/joinRoom.dto';
|
||||
import { setCurrentRoomDto } from './dto/setCurrentRoom.dto';
|
||||
|
||||
@Controller('chat')
|
||||
export class ChatController {
|
||||
|
||||
constructor(
|
||||
private chatService: ChatService,
|
||||
) {}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('myrooms')
|
||||
async getMyRooms(@Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in getMyRooms controller");
|
||||
const rooms = await this.chatService.getMyRooms(req.user);
|
||||
console.log("- out getMyRooms controller");
|
||||
return res.status(HttpStatus.OK).json({ rooms: rooms });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('allrooms')
|
||||
async getAllRooms(@Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in getAllRooms controller");
|
||||
const rooms = await this.chatService.getAllNotMyRooms(req.user);
|
||||
console.log("- out getAllRooms controller");
|
||||
return res.status(HttpStatus.OK).json({ rooms: rooms });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('current')
|
||||
async setCurrentRoom(@Body() setCurrentRoomDto: setCurrentRoomDto, @Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in setCurrentRoom controller");
|
||||
const response = await this.chatService.setCurrentRoom(req.user, setCurrentRoomDto.name);
|
||||
console.log("- out setCurrentRoom controller");
|
||||
return res.status(HttpStatus.OK).json({ message: response });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('create')
|
||||
async createRoom(@Body() createRoomDto: createRoomDto, @Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in createRoom controller");
|
||||
const response = await this.chatService.addUserToNewRoom(req.user, createRoomDto);
|
||||
console.log("- out createRoom controller");
|
||||
return res.status(HttpStatus.OK).json({ room_name: createRoomDto.room_name, message: response });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('join')
|
||||
async joinRoom(@Body() joinRoomDto: joinRoomDto, @Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in joinRoom controller");
|
||||
const response = await this.chatService.addUserToRoom(req.user, joinRoomDto);
|
||||
console.log("- out joinRoom controller");
|
||||
return res.status(HttpStatus.OK).json({ room_name: joinRoomDto.room_name, message: response });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('change')
|
||||
async changeRoom(@Body() joinRoomDto: joinRoomDto, @Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in changeRoom controller");
|
||||
const response = await this.chatService.setCurrentRoom(req.user, joinRoomDto.room_name);
|
||||
console.log("- out changeRoom controller");
|
||||
return res.status(HttpStatus.OK).json({ room_name: joinRoomDto.room_name, message: response });
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Post('leave')
|
||||
async leaveRoom(@Body() body)
|
||||
{
|
||||
console.log("- in leaveRoom controller");
|
||||
console.log("- out leaveRoom controller");
|
||||
}
|
||||
|
||||
@UseGuards(AuthenticateGuard)
|
||||
@UseGuards(TwoFactorGuard)
|
||||
@Get('messages')
|
||||
async getMessages(@Req() req, @Res() res): Promise<object>
|
||||
{
|
||||
console.log("- in getMessages controller");
|
||||
const messages = await this.chatService.getMessagesFromCurrentRoom(req.user);
|
||||
console.log("- out getMessages controller");
|
||||
return res.status(HttpStatus.OK).json({ messages: messages });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import {
|
||||
WebSocketGateway,
|
||||
SubscribeMessage,
|
||||
WebSocketServer,
|
||||
MessageBody,
|
||||
OnGatewayConnection,
|
||||
OnGatewayDisconnect,
|
||||
} from '@nestjs/websockets';
|
||||
import { WebSocketGateway, SubscribeMessage, WebSocketServer, MessageBody, ConnectedSocket, OnGatewayConnection, OnGatewayDisconnect } from '@nestjs/websockets';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { PaginationQueryDto } from 'src/common/dto/pagination-query.dto';
|
||||
import { ChatService } from './chat.service';
|
||||
|
||||
@WebSocketGateway(5000, {
|
||||
path: '/chat',
|
||||
@@ -19,26 +13,43 @@ export class ChatGateway
|
||||
constructor
|
||||
(
|
||||
private usersService: UsersService,
|
||||
private chatService: ChatService,
|
||||
) {}
|
||||
|
||||
@WebSocketServer()
|
||||
server;
|
||||
|
||||
|
||||
// how to guard the handleConnection ?
|
||||
// https://github.com/nestjs/nest/issues/882
|
||||
async handleConnection(client) {
|
||||
// const paginationQuery = new PaginationQueryDto();
|
||||
// const users = await this.usersService.findAll(paginationQuery);
|
||||
console.log('- Client connected :', client.id, client.handshake.query.username);
|
||||
client.username = client.handshake.query.username;
|
||||
}
|
||||
async handleDisconnect(client) {
|
||||
console.log('- Client disconnected :', client.id, client.username);
|
||||
}
|
||||
|
||||
// const users = await this.usersService.findAll(client);
|
||||
// const users = await this.usersService.findAll(client);
|
||||
console.log('---- Client connected :', client.id);
|
||||
// console.log('users :', users);
|
||||
@SubscribeMessage('join')
|
||||
async joinRoom(@ConnectedSocket() socket, @MessageBody() room_name: string): Promise<void>
|
||||
{
|
||||
console.log('- in joinRoom gateway');
|
||||
socket.leave(socket.room);
|
||||
socket.join(room_name);
|
||||
socket.room = room_name;
|
||||
|
||||
console.log('- out joinRoom gateway');
|
||||
}
|
||||
handleDisconnect(client) {
|
||||
console.log('---- client disconnected :', client.id);
|
||||
|
||||
@SubscribeMessage('message')
|
||||
async handleMessage(@ConnectedSocket() socket, @MessageBody() message: string): Promise<void>
|
||||
{
|
||||
console.log('- in handleMessage gateway');
|
||||
//let room_name = await this.chatService.getCurrentRoom(socket.username);
|
||||
socket.to(socket.room).emit('message', socket.username, message);
|
||||
this.chatService.addMessageToCurrentRoom(socket.username, message);
|
||||
|
||||
console.log('- out handleMessage gateway');
|
||||
}
|
||||
/*
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
28
srcs/requirements/nestjs/api_back/src/chat/chat.module.ts
Normal file
28
srcs/requirements/nestjs/api_back/src/chat/chat.module.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ChatController } from './chat.controller';
|
||||
import { ChatService } from './chat.service';
|
||||
import { ChatGateway } from './chat.gateway';
|
||||
import { UsersModule } from 'src/users/users.module';
|
||||
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Chatroom } from './entities/chatroom.entity';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Chatroom, User]),
|
||||
UsersModule,
|
||||
],
|
||||
controllers: [
|
||||
ChatController,
|
||||
],
|
||||
exports: [
|
||||
],
|
||||
providers: [
|
||||
ChatService,
|
||||
ChatGateway,
|
||||
],
|
||||
})
|
||||
|
||||
export class ChatModule {}
|
||||
|
||||
219
srcs/requirements/nestjs/api_back/src/chat/chat.service.ts
Normal file
219
srcs/requirements/nestjs/api_back/src/chat/chat.service.ts
Normal file
@@ -0,0 +1,219 @@
|
||||
import { HttpException, HttpStatus, Injectable, Res } from '@nestjs/common';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
import { Chatroom } from './entities/chatroom.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { createRoomDto } from './dto/createRoom.dto';
|
||||
import { joinRoomDto } from './dto/joinRoom.dto';
|
||||
import { messagesDto } from './dto/messages.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ChatService {
|
||||
|
||||
constructor(
|
||||
private usersService: UsersService,
|
||||
@InjectRepository(User)
|
||||
private readonly userRepository: Repository<User>,
|
||||
@InjectRepository(Chatroom)
|
||||
private readonly chatroomRepository: Repository<Chatroom>,
|
||||
) { }
|
||||
|
||||
|
||||
// temp for test
|
||||
sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
|
||||
/* GETTERS ************************************************
|
||||
*/
|
||||
|
||||
async getMyRooms(user: User)
|
||||
{
|
||||
console.log("-- in getMyRooms service");
|
||||
const rooms = await this.chatroomRepository
|
||||
.createQueryBuilder('chatroom')
|
||||
.where('chatroom.users LIKE :user_name', { user_name: `%${user.username}%` })
|
||||
.getMany();
|
||||
|
||||
console.log("-- out getMyRooms service");
|
||||
return rooms;
|
||||
}
|
||||
|
||||
async getAllRooms()
|
||||
{
|
||||
console.log("-- in getAllRooms service");
|
||||
const rooms = await this.chatroomRepository
|
||||
.createQueryBuilder('chatroom')
|
||||
.getMany();
|
||||
|
||||
console.log("-- out getAllRooms service");
|
||||
return rooms;
|
||||
}
|
||||
|
||||
async getAllNotMyRooms(user: User)
|
||||
{
|
||||
console.log("-- in getAllNotMyRooms service");
|
||||
const user_db = await this.getUserByName(user.username);
|
||||
//const user_db = await this.usersService.findOne(user.username);
|
||||
const rooms = await this.chatroomRepository
|
||||
.createQueryBuilder('chatroom')
|
||||
.where('chatroom.type != :type', { type: 'private' })
|
||||
.andWhere('chatroom.users NOT LIKE :user_name', { user_name: `%${user.username}%` })
|
||||
.getMany();
|
||||
//const users = await this.getAllUsers();
|
||||
//let allRooms = [...rooms, ...users];
|
||||
|
||||
console.log("-- out getAllNotMyRooms service");
|
||||
return rooms;
|
||||
}
|
||||
|
||||
async getMessagesFromCurrentRoom(user: User)
|
||||
{
|
||||
console.log("-- in getMessagesFromCurrentRoom service");
|
||||
const user_db = await this.getUserByName(user.username);
|
||||
//const user_db = await this.usersService.findOne(user.username);
|
||||
const currentRoom = await this.getRoomByName(user_db.currentRoom);
|
||||
|
||||
console.log("-- out getMessagesFromCurrentRoom service");
|
||||
return currentRoom.messages;
|
||||
}
|
||||
|
||||
async getCurrentRoom(username: string)
|
||||
{
|
||||
console.log("-- in getCurrentRoom service");
|
||||
const user_db = await this.getUserByName(username);
|
||||
//const user_db = await this.usersService.findOne(username);
|
||||
|
||||
console.log("-- out getCurrentRoom service");
|
||||
return user_db.currentRoom;
|
||||
}
|
||||
|
||||
async getRoomByName(name: string)
|
||||
{
|
||||
console.log("-- in getRoomByName service");
|
||||
const room = await this.chatroomRepository
|
||||
.createQueryBuilder('chatroom')
|
||||
.where('chatroom.name = :name', { name: name })
|
||||
.getOne();
|
||||
|
||||
console.log("-- out getRoomByName service");
|
||||
return room;
|
||||
}
|
||||
|
||||
async getRoomById(id: number)
|
||||
{
|
||||
console.log("-- in getRoomById service");
|
||||
const room = await this.chatroomRepository
|
||||
.createQueryBuilder('chatroom')
|
||||
.where('chatroom.id = :id', { id: id })
|
||||
.getOne();
|
||||
|
||||
console.log("-- out getRoomById service");
|
||||
return room;
|
||||
}
|
||||
|
||||
|
||||
/* SETTERS ************************************************
|
||||
*/
|
||||
|
||||
async setCurrentRoom(user: User, name: string)
|
||||
{
|
||||
console.log("-- in setCurrentRoom service");
|
||||
const user_db = await this.getUserByName(user.username);
|
||||
//const user_db = await this.usersService.findOne(user.username);
|
||||
user_db.currentRoom = name;
|
||||
this.userRepository.save(user_db);
|
||||
|
||||
console.log("-- out setCurrentRoom service");
|
||||
return `room "${name}" is now current room`;
|
||||
}
|
||||
|
||||
|
||||
/* ADDERS *************************************************
|
||||
*/
|
||||
|
||||
async addUserToNewRoom(user: User, createRoomDto: createRoomDto)
|
||||
{
|
||||
console.log("-- in addUserToRoom service");
|
||||
const room = await this.getRoomByName(createRoomDto.room_name);
|
||||
if (room)
|
||||
throw new HttpException(`This room already exist`, HttpStatus.CONFLICT);
|
||||
|
||||
// create chatroom
|
||||
const newChatroom = new Chatroom();
|
||||
newChatroom.name = createRoomDto.room_name;
|
||||
newChatroom.type = createRoomDto.room_type;
|
||||
newChatroom.owner = user.username;
|
||||
newChatroom.users = [user.username];
|
||||
newChatroom.messages = [{ name: "SERVER", message: `creation of room ${createRoomDto.room_name}` }];
|
||||
this.chatroomRepository.save(newChatroom);
|
||||
|
||||
console.log("-- out addUserToRoom service");
|
||||
return "successfull room creation";
|
||||
}
|
||||
|
||||
async addUserToRoom(user: User, joinRoomDto: joinRoomDto)
|
||||
{
|
||||
console.log("-- in addUserToRoom service");
|
||||
const room = await this.getRoomByName(joinRoomDto.room_name);
|
||||
if (room.users.includes(user.username))
|
||||
throw new HttpException(`your have already join this room`, HttpStatus.CONFLICT);
|
||||
|
||||
// update room with new user
|
||||
room.users.push(user.username);
|
||||
this.chatroomRepository.save(room);
|
||||
|
||||
const rooms = await this.getMyRooms(user);
|
||||
const allRooms = await this.getAllRooms();
|
||||
|
||||
console.log("-- out addUserToRoom service");
|
||||
return "successfull joining room";
|
||||
}
|
||||
|
||||
async addMessageToCurrentRoom(username: string, message: string)
|
||||
{
|
||||
console.log("-- in addMessageToCurrentRoom service");
|
||||
const user_db = await this.getUserByName(username);
|
||||
//const user_db = await this.usersService.findOne(username);
|
||||
const currentRoom = await this.getRoomByName(user_db.currentRoom);
|
||||
let chat_message = {
|
||||
name: username,
|
||||
message: message,
|
||||
};
|
||||
currentRoom.messages.push(chat_message);
|
||||
this.chatroomRepository.save(currentRoom);
|
||||
|
||||
console.log("-- out addMessageToCurrentRoom service");
|
||||
}
|
||||
|
||||
|
||||
/* REMOVERS ***********************************************
|
||||
*/
|
||||
|
||||
async removeUserFromRoom(user: User, room_name: string)
|
||||
{
|
||||
console.log("-- in removeUserFromRoom service");
|
||||
// get room
|
||||
// remove user
|
||||
}
|
||||
|
||||
|
||||
/* SEARCH IN USER *****************************************
|
||||
*/
|
||||
|
||||
async getUserByName(name: string)
|
||||
{
|
||||
console.log("-- in getUserByName service");
|
||||
const user = await this.userRepository
|
||||
.createQueryBuilder('user')
|
||||
.where('user.username = :name', { name: name })
|
||||
.getOne();
|
||||
|
||||
console.log("-- out getUserByName service");
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional } from "class-validator";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
export class createRoomDto
|
||||
{
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
room_name: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
room_type: 'public' | 'private' | 'direct';
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
room_password: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional } from "class-validator";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
export class joinRoomDto
|
||||
{
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
room_name: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional, IsArray } from "class-validator";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
export class messagesDto
|
||||
{
|
||||
@IsArray()
|
||||
messages: { name: string; message: string }[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { IsBoolean, IsEmpty, IsInt, IsNotEmpty, IsNumber, IsString, IsOptional } from "class-validator";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
export class setCurrentRoomDto
|
||||
{
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
name: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
ManyToOne,
|
||||
ManyToMany,
|
||||
JoinTable,
|
||||
PrimaryGeneratedColumn
|
||||
} from "typeorm";
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
|
||||
@Entity('chatroom')
|
||||
export class Chatroom {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
name: string;
|
||||
|
||||
@Column()
|
||||
type: string;
|
||||
|
||||
// @ManyToOne(type => User, user => user.ownedRooms)
|
||||
// owner: User;
|
||||
//
|
||||
// @ManyToMany(type => User)
|
||||
// @JoinTable()
|
||||
// users: User[];
|
||||
|
||||
@Column()
|
||||
owner: string; // name
|
||||
|
||||
@Column("simple-array")
|
||||
users: string[]; // names
|
||||
|
||||
@Column("json")
|
||||
messages: { name: string, message: string }[];
|
||||
}
|
||||
|
||||
@@ -254,7 +254,6 @@ export class FriendshipService {
|
||||
|
||||
// const friendship = await this.friendshipRepository.findOneBy({ sender: creator, receiver: receiver });
|
||||
|
||||
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.leftJoinAndSelect('friendship.sender', 'sender')
|
||||
@@ -459,4 +458,4 @@ export class FriendshipService {
|
||||
console.log('we are not blocked in friendship service')
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,4 +52,9 @@ export class User {
|
||||
@JoinColumn()
|
||||
@OneToOne(() => UserStats, { cascade: true })
|
||||
stats: UserStats;
|
||||
|
||||
// ROOMS :
|
||||
|
||||
@Column({ nullable: true })
|
||||
currentRoom: string; // chatroom name
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ export class UsersService {
|
||||
isEnabledTwoFactorAuth: user.isEnabledTwoFactorAuth,
|
||||
status: user.status,
|
||||
stats: user.stats,
|
||||
currentRoom: user.currentRoom,
|
||||
};
|
||||
console.log(`Returned Partial User.` + partialUser.username + user.username);
|
||||
return partialUser;
|
||||
|
||||
2
srcs/requirements/svelte/api_front/.env
Normal file
2
srcs/requirements/svelte/api_front/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
WEBSITE_HOST=localhost
|
||||
WEBSITE_PORT=8080
|
||||
24328
srcs/requirements/svelte/api_front/public/build/bundle.js
Normal file
24328
srcs/requirements/svelte/api_front/public/build/bundle.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,54 +1,11 @@
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
import Layouts from './Chat_layouts.svelte';
|
||||
import { init_socket } from './Socket_init';
|
||||
|
||||
export let color = "transparent";
|
||||
|
||||
/* web sockets with socket.io
|
||||
*/
|
||||
import { onMount } from 'svelte';
|
||||
import io from 'socket.io-client';
|
||||
const socket = io(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`, {
|
||||
path: '/chat'
|
||||
});
|
||||
onMount(async => {
|
||||
socket.on('connect', function(){
|
||||
console.log("socket.io connected");
|
||||
});
|
||||
socket.on('disconnect', function(){
|
||||
console.log("socket.io disconnected");
|
||||
});
|
||||
socket.on('connect_error', function(){
|
||||
console.log("socket.io connect_error");
|
||||
});
|
||||
socket.on('connect_timeout', function(){
|
||||
console.log("socket.io connect_timeout");
|
||||
});
|
||||
socket.on('error', function(){
|
||||
console.log("socket.io error");
|
||||
});
|
||||
socket.on('reconnect', function(){
|
||||
console.log("socket.io reconnect");
|
||||
});
|
||||
socket.on('reconnect_attempt', function(){
|
||||
console.log("socket.io reconnect_attempt");
|
||||
});
|
||||
socket.on('reconnecting', function(){
|
||||
console.log("socket.io reconnecting");
|
||||
});
|
||||
socket.on('reconnect_error', function(){
|
||||
console.log("socket.io reconnect_error");
|
||||
});
|
||||
socket.on('reconnect_failed', function(){
|
||||
console.log("socket.io reconnect_failed");
|
||||
});
|
||||
socket.on('ping', function(){
|
||||
console.log("socket.io ping");
|
||||
});
|
||||
socket.on('pong', function(){
|
||||
console.log("socket.io pong");
|
||||
});
|
||||
});
|
||||
init_socket();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
|
||||
export let color;
|
||||
export let layout;
|
||||
|
||||
</script>
|
||||
|
||||
<div class="{layout} chat_box" style="background-color: {color};">
|
||||
<div class="{$layout} chat_box" style="background-color: {color};">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
import Debug from './tmp_debug.svelte';
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
import ChatBox from './Chat_box_css.svelte';
|
||||
|
||||
import CloseLayout from './Layout_close.svelte';
|
||||
@@ -14,68 +16,75 @@
|
||||
import MuteLayout from './Layout_mute.svelte';
|
||||
import UserLayout from './Layout_user.svelte';
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
/* global variables
|
||||
*/
|
||||
export let color;
|
||||
let room = "";
|
||||
let admin = false;
|
||||
let layout = "close";
|
||||
let layouts = ["home", "home"];
|
||||
|
||||
/* hold previous version of layout, to go back
|
||||
*/
|
||||
function set_layouts(layout)
|
||||
function set_layouts($layout)
|
||||
{
|
||||
if (layout === "close")
|
||||
console.log("layouts:", layouts);
|
||||
console.log("layout:", $layout);
|
||||
if ($layout.length === 0)
|
||||
layout.set(layouts[0]);
|
||||
else if ($layout === "close")
|
||||
return;
|
||||
if (layout === layouts[0])
|
||||
else if ($layout === layouts[0])
|
||||
return;
|
||||
if (layout === layouts[1])
|
||||
layouts = [layout, "home"];
|
||||
else if ($layout === layouts[1])
|
||||
layouts = [$layout, "home"];
|
||||
else
|
||||
layouts = [layout, layouts[0]];
|
||||
layouts = [$layout, layouts[0]];
|
||||
console.log("- layouts:", layouts);
|
||||
}
|
||||
$: set_layouts(layout);
|
||||
$: set_layouts($layout);
|
||||
|
||||
</script>
|
||||
|
||||
<ChatBox layout={layout} color={color}>
|
||||
<ChatBox color={color}>
|
||||
|
||||
{#if layout === "home"}
|
||||
<HomeLayout bind:layout />
|
||||
{#if $layout === "home"}
|
||||
<HomeLayout />
|
||||
|
||||
{:else if layout === "close"}
|
||||
<CloseLayout bind:layout />
|
||||
{:else if $layout === "close"}
|
||||
<CloseLayout back={layouts[0]} />
|
||||
|
||||
{:else if layout === "room"}
|
||||
<RoomLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "room"}
|
||||
<RoomLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "new"}
|
||||
<NewLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "new"}
|
||||
<NewLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "settings"}
|
||||
<SettingsLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "settings"}
|
||||
<SettingsLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "room_set"}
|
||||
<RoomsetLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "room_set"}
|
||||
<RoomsetLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "protected"}
|
||||
<ProtectedLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "protected"}
|
||||
<ProtectedLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "create"}
|
||||
<CreateLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "create"}
|
||||
<CreateLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "mute"}
|
||||
<MuteLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "mute"}
|
||||
<MuteLayout back={layouts[1]} />
|
||||
|
||||
{:else if layout === "user"}
|
||||
<UserLayout bind:layout back={layouts[1]} />
|
||||
{:else if $layout === "user"}
|
||||
<UserLayout back={layouts[1]} />
|
||||
|
||||
{/if}
|
||||
|
||||
</ChatBox>
|
||||
|
||||
<!-- TMP DEBUG -->
|
||||
<Debug bind:layouts />
|
||||
|
||||
<style></style>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
<!--
|
||||
<Button
|
||||
bind:layout
|
||||
@@ -13,14 +12,15 @@
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
import { layout } from './Store_chat';
|
||||
|
||||
export let my_class = "";
|
||||
export let my_title = "";
|
||||
export let layout = "";
|
||||
export let new_layout = "";
|
||||
export let on_click = "";
|
||||
|
||||
function update_layout() {
|
||||
layout = new_layout;
|
||||
layout.set(new_layout);
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -67,7 +67,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* for btn list
|
||||
/* .list
|
||||
*/
|
||||
.list:not(:hover) {
|
||||
background-color: rgb(240, 240, 240);
|
||||
@@ -77,14 +77,14 @@
|
||||
}
|
||||
|
||||
|
||||
/* for transparent btn
|
||||
/* .transparent
|
||||
*/
|
||||
.transparent:not(:hover) {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
/* for deactivated btn
|
||||
/* .deactivated
|
||||
*/
|
||||
.deactivate {
|
||||
background-color: transparent;
|
||||
@@ -92,7 +92,40 @@
|
||||
}
|
||||
|
||||
|
||||
/* for icon
|
||||
/* .border
|
||||
*/
|
||||
.border {
|
||||
border: 1px solid rgb(150, 150, 150);
|
||||
}
|
||||
|
||||
|
||||
/* .light
|
||||
*/
|
||||
.light {
|
||||
background-color: rgb(233, 233, 233);
|
||||
}
|
||||
.light.border {
|
||||
border: 1px solid rgb(204, 204, 204);
|
||||
}
|
||||
.light:hover {
|
||||
background-color: rgb(220, 220, 220);
|
||||
}
|
||||
.light.border:hover {
|
||||
border-color: rgb(200, 200, 200);
|
||||
}
|
||||
.light:active {
|
||||
background-color: rgb(210, 210, 210);
|
||||
}
|
||||
|
||||
|
||||
/* .thin
|
||||
*/
|
||||
.thin p {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
|
||||
/* .icon
|
||||
*/
|
||||
.icon p {
|
||||
display: none;
|
||||
@@ -107,7 +140,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* for 3 dots btn
|
||||
/* .dots
|
||||
*/
|
||||
.dots::after {
|
||||
content: '\2807';
|
||||
@@ -123,7 +156,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* for close btn
|
||||
/* .close
|
||||
*/
|
||||
.close::before {
|
||||
content: "";
|
||||
@@ -136,7 +169,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* for back btn
|
||||
/* .back
|
||||
*/
|
||||
.back::before {
|
||||
content: "";
|
||||
@@ -151,7 +184,7 @@
|
||||
}
|
||||
|
||||
|
||||
/* for blocked user
|
||||
/* .blocked
|
||||
https://www.fileformat.info/info/unicode/category/So/list.htm
|
||||
U+1F512 LOCK 🔒
|
||||
U+1F513 OPEN LOCK 🔓
|
||||
@@ -0,0 +1,11 @@
|
||||
<script>
|
||||
|
||||
export let content = "warning";
|
||||
export let bg_color = "rgb(201, 87, 34)";
|
||||
export let color = "rgb(240, 240, 240)";
|
||||
|
||||
</script>
|
||||
|
||||
<p style="background-color: {bg_color}; color: {color};">
|
||||
{content}
|
||||
</p>
|
||||
@@ -1,13 +1,14 @@
|
||||
<script lang="ts">
|
||||
|
||||
<script>
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout;
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
<Button bind:layout new_layout="home" my_class="chat">
|
||||
<Button new_layout={back} my_class="chat">
|
||||
chat
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,41 @@
|
||||
<script lang="ts">
|
||||
|
||||
<script>
|
||||
import { msgs, layout } from './Store_chat';
|
||||
import { change_room, create_room } from './Request_rooms';
|
||||
import Button from './Element_button.svelte';
|
||||
import Warning from './Element_warning.svelte';
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
export let back = "";
|
||||
|
||||
let room_name: string;
|
||||
let room_type: string;
|
||||
let room_password: string;
|
||||
let response = {
|
||||
status: 0,
|
||||
message: "",
|
||||
}
|
||||
|
||||
async function handleSubmit(evt)
|
||||
{
|
||||
let formIsValid = evt.target.checkValidity();
|
||||
|
||||
if (!formIsValid)
|
||||
return;
|
||||
|
||||
// send the new room
|
||||
response = await create_room(room_name, room_type);
|
||||
|
||||
// go to room
|
||||
if (response.status === 200)
|
||||
await change_room(room_name);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,37 +45,45 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
<!-- panel_create -->
|
||||
<div class="panel panel_create">
|
||||
<form>
|
||||
<div class="panel panel_create __border_top">
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
{#if response.status >= 300}
|
||||
<Warning content={response.message}/>
|
||||
{/if}
|
||||
<!-- name: -->
|
||||
<label for="chat_name"><p>new room name :</p></label>
|
||||
<input id="chat_name" required>
|
||||
<input id="chat_name" bind:value={room_name} name="room_name" required>
|
||||
<!-- [ ] pubic -->
|
||||
<input id="chat_public" type="radio" name="chat_create_type" checked>
|
||||
<label for="chat_public" class="_radio"><p>public</p></label>
|
||||
<label for="chat_public" class="_radio">
|
||||
<p>public</p>
|
||||
<input id="chat_public" bind:group={room_type} type="radio" name="room_type" value="public" required>
|
||||
</label>
|
||||
<!-- [ ] private -->
|
||||
<input id="chat_private" type="radio" name="chat_create_type">
|
||||
<label for="chat_private" class="_radio"><p>private</p></label>
|
||||
<label for="chat_private" class="_radio hide">
|
||||
<p>private</p>
|
||||
<input id="chat_private" bind:group={room_type} type="radio" name="room_type" value="private" required>
|
||||
</label>
|
||||
<!-- [ ] protected -->
|
||||
<input id="chat_protected" class="__check_change_next" type="radio" name="chat_create_type">
|
||||
<label for="chat_protected" class="_radio"><p>protected</p></label>
|
||||
<label for="chat_protected" class="_radio hide">
|
||||
<p>protected</p>
|
||||
<input id="chat_protected" bind:group={room_type} type="radio" name="room_type" value="protected" required>
|
||||
</label>
|
||||
<!-- [x] protected -->
|
||||
<div class="__to_show">
|
||||
<label for="chat_pswd"><p>choose a password :</p></label>
|
||||
<input id="chat_pswd" type="password" placeholder="minimum 8 characters" minlength="8">
|
||||
<p>confirm password :</p>
|
||||
<input type="password">
|
||||
</div>
|
||||
{#if room_type === 'protected'}
|
||||
<div>
|
||||
<label for="chat_pswd"><p>choose a password :</p></label>
|
||||
<input id="chat_pswd" bind:value={room_password} type="password" placeholder="minimum 8 characters" minlength="8" name="password" required>
|
||||
</div>
|
||||
{/if}
|
||||
<input type="submit" value="⮡">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -68,42 +101,32 @@
|
||||
/ auto 1fr auto ;
|
||||
}
|
||||
|
||||
/* temp
|
||||
*/
|
||||
.hide {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* radio elements style check
|
||||
*/
|
||||
form input[type=radio] {
|
||||
display: none;
|
||||
}
|
||||
form label._radio {
|
||||
margin: 0px 20px 0px auto;
|
||||
.panel label._radio {
|
||||
display: inline;
|
||||
margin: 10px 0px 0px auto;
|
||||
padding-right: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
form label._radio p {
|
||||
.panel label._radio * {
|
||||
display: inline;
|
||||
}
|
||||
.panel label._radio p {
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
form label._radio::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: calc(50% - 6px);
|
||||
right: 0px;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 6px;
|
||||
border: 2px solid rgb(150, 150, 150);
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
}
|
||||
form input[type=radio]:checked
|
||||
+ label._radio::after {
|
||||
background-color: rgb(200, 200, 200);
|
||||
}
|
||||
|
||||
|
||||
/* submit
|
||||
*/
|
||||
form input[type=submit] {
|
||||
.panel input[type=submit] {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout;
|
||||
import { layout, msgs, user } from './Store_chat';
|
||||
import { change_room, get_room_messages, get_all_rooms } from './Request_rooms';
|
||||
import { onMount } from 'svelte';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
let rooms = get_all_rooms();
|
||||
|
||||
// go to clicked room
|
||||
async function go_to_room(evt)
|
||||
{
|
||||
console.log("inside go_to_room");
|
||||
await change_room(evt.target.innerText);
|
||||
await get_room_messages();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- settings -->
|
||||
<Button bind:layout new_layout="settings" my_class="settings dots icon">
|
||||
<Button new_layout="settings" my_class="settings dots icon">
|
||||
settings
|
||||
</Button>
|
||||
|
||||
<!-- new -->
|
||||
<Button bind:layout new_layout="new" my_class="new transparent">
|
||||
<Button new_layout="new" my_class="new transparent">
|
||||
new
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
@@ -30,18 +41,16 @@
|
||||
<div class="__show_if_only_child">
|
||||
<p class="__center">/ you have no chat room yet /</p>
|
||||
</div>
|
||||
<!-- placeholders
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
a room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
another room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
placeholder
|
||||
</Button>
|
||||
------------- -->
|
||||
<!-- END placeholders -->
|
||||
{#await rooms}
|
||||
<!-- promise is pending -->
|
||||
<p>rooms are loaded...</p>
|
||||
{:then rooms}
|
||||
{#each rooms as room}
|
||||
<Button my_class="list" on_click={go_to_room}>
|
||||
{room.name}
|
||||
</Button>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -1,16 +1,40 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout, msgs, user, socket } from './Store_chat';
|
||||
import { join_room, change_room, get_room_messages } from './Request_rooms';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let rooms = [];
|
||||
|
||||
// ask api for the rooms
|
||||
const get_rooms = fetch('/api/v2/chat/allrooms')
|
||||
.then(resp => resp.json())
|
||||
.then(data =>
|
||||
{
|
||||
console.log("data.rooms:", data.rooms);
|
||||
for (let room of data.rooms)
|
||||
console.log(room.name);
|
||||
rooms = data.rooms;
|
||||
});
|
||||
|
||||
// join the room
|
||||
async function join_rooms(evt)
|
||||
{
|
||||
console.log("inside join_room");
|
||||
let room_name = evt.target.innerText;
|
||||
|
||||
await join_room(room_name);
|
||||
await change_room(room_name);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,13 +44,13 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
<!-- panel_new -->
|
||||
<div class="panel panel_new __border_top">
|
||||
<Button bind:layout new_layout="create" my_class="create">
|
||||
<Button new_layout="create" my_class="create">
|
||||
create
|
||||
</Button>
|
||||
<p>join room :</p>
|
||||
@@ -34,36 +58,16 @@
|
||||
<div class="__show_if_only_child">
|
||||
<p class="__center">/ there are no public rooms yet /</p>
|
||||
</div>
|
||||
<!-- placeholders
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
placeholder
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
join room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
one room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
another room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
one room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
another room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
one room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
another room
|
||||
</Button>
|
||||
<Button bind:layout new_layout="room" my_class="list">
|
||||
one more room
|
||||
</Button>
|
||||
------------- -->
|
||||
<!-- END placeholders -->
|
||||
{#await get_rooms}
|
||||
<!-- promise is pending -->
|
||||
<p>rooms are loaded...</p>
|
||||
{:then}
|
||||
{#each rooms as room}
|
||||
<Button my_class="list" on_click={join_rooms}>
|
||||
{room.name}
|
||||
</Button>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -1,36 +1,28 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
import Msg from './Chat_msg.svelte';
|
||||
import io from 'socket.io-client';
|
||||
import { layout, socket, msgs, add_msg, room_name } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
import Msg from './Element_msg.svelte';
|
||||
|
||||
export let layout = "";
|
||||
export let back = "";
|
||||
|
||||
let msg = "";
|
||||
let text_area;
|
||||
let msgs = [];
|
||||
|
||||
function add_msg(from, the_msg)
|
||||
{
|
||||
msgs = [...msgs, { content: the_msg, name: from }];
|
||||
}
|
||||
|
||||
function send_msg()
|
||||
{
|
||||
msg = msg.trim();
|
||||
|
||||
if (msg.length > 0) {
|
||||
//socket.emit('sendmsg', msg);
|
||||
socket.emit('message', msg);
|
||||
add_msg("me", msg);
|
||||
console.log(msgs);
|
||||
}
|
||||
|
||||
msg = "";
|
||||
text_area.focus();
|
||||
}
|
||||
|
||||
function send_msg_if(evt)
|
||||
function enter_send_msg(evt)
|
||||
{
|
||||
if (evt.shiftKey && evt.key === "Enter")
|
||||
{
|
||||
@@ -44,25 +36,25 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
<!-- room_name -->
|
||||
<Button bind:layout new_layout="room_set" my_class="room_name transparent">
|
||||
<room_name>
|
||||
<Button new_layout="room_set" my_class="room_name transparent">
|
||||
{$room_name}
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
<!-- msg -->
|
||||
<div class="panel panel_msg">
|
||||
<div class="msg_thread">
|
||||
{#each msgs as msg}
|
||||
<Msg name={msg.name}>{@html msg.content}</Msg>
|
||||
{#each $msgs as msg}
|
||||
<Msg name={msg.name}>{@html msg.message}</Msg>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,7 +65,7 @@
|
||||
class="text_area"
|
||||
bind:innerHTML={msg}
|
||||
bind:this={text_area}
|
||||
on:keypress={send_msg_if}
|
||||
on:keypress={enter_send_msg}
|
||||
contenteditable="true"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
<!-- panel_room_set -->
|
||||
<div class="panel panel_room_set __border_top">
|
||||
<Button bind:layout new_layout="create" my_class="create">
|
||||
<Button new_layout="create" my_class="create">
|
||||
leave
|
||||
</Button>
|
||||
<p>room users :</p>
|
||||
@@ -36,16 +36,16 @@
|
||||
</div>
|
||||
<!-- placeholders
|
||||
------------- -->
|
||||
<Button bind:layout new_layout="user" my_class="list">
|
||||
<Button new_layout="user" my_class="list">
|
||||
user 1
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list blocked">
|
||||
<Button new_layout="user" my_class="list blocked">
|
||||
user 2
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list">
|
||||
<Button new_layout="user" my_class="list">
|
||||
user 3
|
||||
</Button>
|
||||
<Button bind:layout new_layout="user" my_class="list">
|
||||
<Button new_layout="user" my_class="list">
|
||||
user 4
|
||||
</Button>
|
||||
<!-- END placeholders -->
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
</script>
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
<script>
|
||||
|
||||
import Button from './Chat_button.svelte';
|
||||
export let layout = "";
|
||||
import { layout } from './Store_chat';
|
||||
import Button from './Element_button.svelte';
|
||||
|
||||
export let back = "";
|
||||
|
||||
let mute = "mute";
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="grid_box">
|
||||
|
||||
<!-- back -->
|
||||
<Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
<Button new_layout={back} my_class="back icon" my_title="go back {back}">
|
||||
back
|
||||
</Button>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</Button>
|
||||
|
||||
<!-- close -->
|
||||
<Button bind:layout new_layout="close" my_class="close icon">
|
||||
<Button new_layout="close" my_class="close icon">
|
||||
close
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import { msgs, user, layout, socket, room_name } from './Store_chat';
|
||||
|
||||
export async function get_room_messages()
|
||||
{
|
||||
console.log("in get_room_messages");
|
||||
const response = await fetch('/api/v2/chat/messages');
|
||||
const data = await response.json();
|
||||
const messages = data.messages;
|
||||
|
||||
messages.forEach(function(item) {
|
||||
if (item.name === user.username) {
|
||||
item.name = "me";
|
||||
}
|
||||
});
|
||||
|
||||
msgs.set(messages);
|
||||
}
|
||||
|
||||
export async function create_room(room_name, room_type)
|
||||
{
|
||||
console.log("in create_room");
|
||||
|
||||
let form_data = {
|
||||
room_name: room_name,
|
||||
room_type: room_type,
|
||||
};
|
||||
|
||||
// send the new room
|
||||
const response = await fetch('/api/v2/chat/create', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(form_data),
|
||||
});
|
||||
|
||||
// get response status and message
|
||||
let response_status = response.status;
|
||||
let data = await response.json();
|
||||
let response_message = "";
|
||||
if (data.message)
|
||||
response_message = data.message;
|
||||
|
||||
return {
|
||||
status: response_status,
|
||||
message: response_message
|
||||
};
|
||||
}
|
||||
|
||||
export async function join_room(room_name)
|
||||
{
|
||||
console.log("in join_room");
|
||||
|
||||
let name = {
|
||||
room_name: room_name,
|
||||
}
|
||||
const response = await fetch('/api/v2/chat/join', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(name),
|
||||
});
|
||||
let data = await response.json();
|
||||
console.log(data.message);
|
||||
|
||||
socket.emit('join', room_name);
|
||||
}
|
||||
|
||||
export async function change_room(name)
|
||||
{
|
||||
console.log("in change_room");
|
||||
|
||||
let r_name = {
|
||||
room_name: name,
|
||||
}
|
||||
const response = await fetch('/api/v2/chat/change', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(r_name),
|
||||
});
|
||||
let data = await response.json();
|
||||
console.log(data.message);
|
||||
|
||||
await get_room_messages();
|
||||
socket.emit('join', name);
|
||||
|
||||
room_name.set(name);
|
||||
layout.set("room");
|
||||
}
|
||||
|
||||
export async function get_all_rooms()
|
||||
{
|
||||
console.log("in get_all_rooms");
|
||||
|
||||
// ask api for the rooms
|
||||
const response = await fetch('/api/v2/chat/myrooms');
|
||||
const data = await response.json();
|
||||
|
||||
console.log("data.rooms:", data.rooms);
|
||||
for (let room of data.rooms)
|
||||
console.log(room.name);
|
||||
let rooms = data.rooms;
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { user, msgs } from './Store_chat';
|
||||
|
||||
export function socket_events(socket)
|
||||
{
|
||||
socket.on('message', function(from, message)
|
||||
{
|
||||
console.log("received msg:", message, from);
|
||||
if (from === user.username)
|
||||
from = "me";
|
||||
msgs.update(msgs => [...msgs, { name: from, message: message }]);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import io from 'socket.io-client';
|
||||
import { set_socket, set_user } from './Store_chat';
|
||||
import { socket_events } from './Socket_events';
|
||||
|
||||
const address = `http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}`;
|
||||
|
||||
export async function init_socket()
|
||||
{
|
||||
const response = await fetch(`${address}/api/v2/user`);
|
||||
const response_data = await response.json();
|
||||
|
||||
set_user(response_data);
|
||||
|
||||
let socket = await io(address,
|
||||
{
|
||||
path: '/chat',
|
||||
query:
|
||||
{
|
||||
username: response_data.username,
|
||||
},
|
||||
});
|
||||
set_socket(socket);
|
||||
|
||||
socket.on('connect', function(){ console.log("socket.io connected"); });
|
||||
socket.on('disconnect', function(){ console.log("socket.io disconnected"); });
|
||||
socket.on('connect_error', function(){ console.log("socket.io connect_error"); });
|
||||
socket.on('connect_timeout', function(){ console.log("socket.io connect_timeout"); });
|
||||
socket.on('error', function(){ console.log("socket.io error"); });
|
||||
socket.on('reconnect', function(){ console.log("socket.io reconnect"); });
|
||||
socket.on('reconnect_attempt', function(){ console.log("socket.io reconnect_attempt"); });
|
||||
socket.on('reconnecting', function(){ console.log("socket.io reconnecting"); });
|
||||
socket.on('reconnect_error', function(){ console.log("socket.io reconnect_error"); });
|
||||
socket.on('reconnect_failed', function(){ console.log("socket.io reconnect_failed"); });
|
||||
socket.on('ping', function(){ console.log("socket.io ping"); });
|
||||
socket.on('pong', function(){ console.log("socket.io pong"); });
|
||||
|
||||
socket_events(socket);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export let msgs = writable([]);
|
||||
export let layout = writable("close");
|
||||
export let room_name = writable("");
|
||||
|
||||
export let user;
|
||||
export let socket;
|
||||
|
||||
export function set_user(new_user) { user = new_user; }
|
||||
export function set_socket(new_socket) { socket = new_socket; }
|
||||
|
||||
export function add_msg(name: string, message: string)
|
||||
{
|
||||
msgs.update(msgs => [...msgs, { name: "me", message: message }]);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<script>
|
||||
|
||||
export let layout = "";
|
||||
export let layouts = [];
|
||||
|
||||
</script>
|
||||
|
||||
<div style="display: flex; flex-direction: column; font-size: 12px; position: fixed; top: 20px; left: 20px; background-color: white;">
|
||||
<p>temp, for testing :</p>
|
||||
<button on:click={function(){layout = "close" }}>close</button>
|
||||
<button on:click={function(){layout = "home" }}>home</button>
|
||||
<button on:click={function(){layout = "room" }}>room</button>
|
||||
<button on:click={function(){layout = "new" }}>new</button>
|
||||
<button on:click={function(){layout = "settings" }}>settings</button>
|
||||
<button on:click={function(){layout = "room_set" }}>room_set</button>
|
||||
<button on:click={function(){layout = "protected"}}>protected</button>
|
||||
<button on:click={function(){layout = "create" }}>create</button>
|
||||
<button on:click={function(){layout = "mute" }}>mute</button>
|
||||
<button on:click={function(){
|
||||
layouts = ["settings", "settings"];
|
||||
layout = "user";
|
||||
}}>user from settings</button>
|
||||
<button on:click={function(){
|
||||
layouts = ["room_set", "room_set"];
|
||||
layout = "user";
|
||||
}}>user from room_set</button>
|
||||
</div>
|
||||
85
tests_hugo/README.md
Normal file
85
tests_hugo/README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
```
|
||||
fetch conversations
|
||||
___________________
|
||||
| _ |
|
||||
| no conversation | if len == 0
|
||||
| |
|
||||
| [join public] |
|
||||
| |
|
||||
| [start new] |
|
||||
| |
|
||||
|...................|
|
||||
| |
|
||||
|___________________|
|
||||
___________________
|
||||
| convs _ |
|
||||
|___________________| if len > 0
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|___________________|
|
||||
| |send |
|
||||
|_____________|_____|
|
||||
___________________
|
||||
| convs _ |
|
||||
|_ ____________|
|
||||
| .list |
|
||||
| .of |
|
||||
| .convs |
|
||||
| |
|
||||
| |
|
||||
|___________________|
|
||||
| |send |
|
||||
|_____________|_____|
|
||||
___________________
|
||||
| [join public] _ |
|
||||
| | if join_public
|
||||
| .list | fetch public_conversations
|
||||
| .of |
|
||||
| .public |
|
||||
| .convs |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|___________________|
|
||||
___________________
|
||||
| [start new] _ |
|
||||
| | if start_new
|
||||
| .list | fetch friends
|
||||
| .of |
|
||||
| .friends |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|___________________|
|
||||
___________________
|
||||
| convs _ |
|
||||
|___________________| if click_on_list_element
|
||||
| .blablabla | fetch conversation(list_element)
|
||||
| blablabla. |
|
||||
| .bla | --server side--
|
||||
| blabla. | if conversation_exist
|
||||
| bla. | return text
|
||||
|___________________| else if is_allowed
|
||||
| |send | return "start conv"
|
||||
|_____________|_____|
|
||||
|
||||
```
|
||||
|
||||
### goals :
|
||||
- own messages are not sent to myself and directly printed
|
||||
- i can create a room
|
||||
- my messages are sent to other people in room
|
||||
- i can choose in which room to send the messages
|
||||
|
||||
### routes :
|
||||
- https://transcendance:8080/api/v2/chat/conversations
|
||||
- returns list of objects, each object contains :
|
||||
- id: unique conv identification
|
||||
- title: name of the conversation (name of other guy if direct message)
|
||||
-
|
||||
|
||||
|
||||
16
tests_hugo/chat_nest/README.md
Normal file
16
tests_hugo/chat_nest/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
https://www.youtube.com/watch?v=7xpLYk4q0Sg
|
||||
|
||||
npm install (to install packages)
|
||||
npm run start:dev
|
||||
|
||||
|
||||
- [ ] can create chat-rooms (public/private, password protected)
|
||||
- [ ] send direct messages
|
||||
- [ ] block other users
|
||||
- [ ] creators of chat-room are owners, untill they leave
|
||||
- [ ] chat-room owner can set, change, remove password
|
||||
- [ ] chat-room owner is administrator and can set other administrators
|
||||
- [ ] administrators can ban or mute for a time other users
|
||||
- [ ] send game invitation in chat
|
||||
- [ ] view user profiles from chat
|
||||
|
||||
57
tests_hugo/chat_nest/chat_client/chat.html
Normal file
57
tests_hugo/chat_nest/chat_client/chat.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="./style/chat.css" type="text/css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<input type="checkbox" id="chat_input" style="display: none;"/>
|
||||
|
||||
<div class="chat_box">
|
||||
|
||||
<div class="chat_item controls_area">
|
||||
</div>
|
||||
|
||||
<label class="chat_item open_close button" for="chat_input">
|
||||
<p>chat</p>
|
||||
</label>
|
||||
|
||||
<div class="chat_item msg_thread">
|
||||
<div class="msg_box" id="msg_thread">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="chat_item msg_write">
|
||||
<!--
|
||||
<textarea class="text_area" id="msg_write">
|
||||
</textarea>
|
||||
-->
|
||||
<div class="text_area" id="msg_write" contenteditable>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="chat_item msg_send button" onclick="submit_new_message()">
|
||||
<p>send</p>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- https://socket.io/docs/v4/client-installation/ -->
|
||||
<!-- https://socket.io/docs/v4/client-api/ -->
|
||||
<script src="https://cdn.socket.io/4.5.3/socket.io.min.js" integrity="sha384-WPFUvHkB1aHA5TDSZi6xtDgkF0wXJcIIxXhC6h8OT8EH3fC5PWro5pWJ1THjcfEi" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
const socket = io("http://localhost:3000");
|
||||
socket.on("connect", () => {
|
||||
console.log("client: connection");
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="./chat_submit_msg.js"></script>
|
||||
<script src="./chat_receive_msg.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
20
tests_hugo/chat_nest/chat_client/chat_receive_msg.js
Normal file
20
tests_hugo/chat_nest/chat_client/chat_receive_msg.js
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
socket.on('message', ({ data }) => {
|
||||
handle_new_message(data);
|
||||
});
|
||||
|
||||
const handle_new_message = (message) => {
|
||||
const div_thread = document.getElementById('msg_thread');
|
||||
|
||||
console.log("received message:");
|
||||
console.log(`[${message}]`);
|
||||
|
||||
div_thread.appendChild(build_new_message(message));
|
||||
}
|
||||
|
||||
const build_new_message = (message) => {
|
||||
const p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(message));
|
||||
return p;
|
||||
}
|
||||
|
||||
17
tests_hugo/chat_nest/chat_client/chat_submit_msg.js
Normal file
17
tests_hugo/chat_nest/chat_client/chat_submit_msg.js
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
const submit_new_message = () => {
|
||||
const div_msg = document.getElementById('msg_write');
|
||||
/*
|
||||
const msg = div_msg.value;
|
||||
const msg = div_msg.innerText;
|
||||
*/
|
||||
const msg = div_msg.innerText.trim();
|
||||
|
||||
console.log("msg:");
|
||||
console.log(`[${msg}]`);
|
||||
console.log(msg.length);
|
||||
|
||||
if (msg.length > 0)
|
||||
socket.emit('message', { data: msg });
|
||||
}
|
||||
|
||||
103
tests_hugo/chat_nest/chat_client/style/chat.css
Normal file
103
tests_hugo/chat_nest/chat_client/style/chat.css
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
@import 'msg_thread.css';
|
||||
@import 'msg_write.css';
|
||||
|
||||
/**
|
||||
* GRID
|
||||
*/
|
||||
|
||||
/* global settings */
|
||||
|
||||
.chat_box * {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.chat_box .chat_item.controls_area { grid-area: controls;}
|
||||
.chat_box .chat_item.open_close { grid-area: open_close;}
|
||||
.chat_box .chat_item.msg_thread { grid-area: msg_thread;}
|
||||
.chat_box .chat_item.msg_write { grid-area: msg_write;}
|
||||
.chat_box .chat_item.msg_send { grid-area: msg_send;}
|
||||
.chat_box {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
display: grid;
|
||||
grid:
|
||||
' controls open_close ' auto
|
||||
' msg_thread msg_thread ' 1fr
|
||||
' msg_write msg_send ' auto
|
||||
/ 1fr auto;
|
||||
gap: 0px;
|
||||
padding: 0px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
border: 1px solid green;
|
||||
}
|
||||
.chat_box .chat_item {
|
||||
/*
|
||||
border: 1px solid blue;
|
||||
*/
|
||||
}
|
||||
/* buttons settings */
|
||||
.chat_box .chat_item.button {
|
||||
display: flex;
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
border: none;
|
||||
background-color: rgb(220, 220, 220);
|
||||
}
|
||||
.chat_box .chat_item.button p {
|
||||
margin: auto;
|
||||
}
|
||||
.chat_box .chat_item.button:hover {
|
||||
background-color: rgb(200, 200, 200);
|
||||
}
|
||||
.chat_box .chat_item.button:active {
|
||||
background-color: rgb(220, 220, 220);
|
||||
}
|
||||
/* collapse settings */
|
||||
.chat_box .chat_item:not(.open_close) {
|
||||
display: none;
|
||||
}
|
||||
#chat_input:checked +
|
||||
.chat_box {
|
||||
gap: 5px;
|
||||
padding: 5px;
|
||||
width: 300px;
|
||||
height: 400px;
|
||||
}
|
||||
#chat_input:checked +
|
||||
.chat_box .chat_item {
|
||||
display: flex;
|
||||
}
|
||||
#chat_input:checked +
|
||||
.chat_box .chat_item.open_close p {
|
||||
display: none;
|
||||
}
|
||||
#chat_input:checked +
|
||||
.chat_box .chat_item.open_close {
|
||||
/*
|
||||
*/
|
||||
width: 30px;
|
||||
height: 20px;
|
||||
padding: 0px;
|
||||
justify-self: end;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
}
|
||||
#chat_input:checked +
|
||||
.chat_box .chat_item.open_close::before {
|
||||
--collapse_width: 20px;
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
height: 2px;
|
||||
width: 15px;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
4
tests_hugo/chat_nest/chat_client/style/msg_thread.css
Normal file
4
tests_hugo/chat_nest/chat_client/style/msg_thread.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.chat_box .chat_item .msg_box {
|
||||
width: 100%;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
16
tests_hugo/chat_nest/chat_client/style/msg_write.css
Normal file
16
tests_hugo/chat_nest/chat_client/style/msg_write.css
Normal file
@@ -0,0 +1,16 @@
|
||||
.chat_box .text_area {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 100%;
|
||||
max-height: 300px;
|
||||
/*
|
||||
resize: none;
|
||||
*/
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
background-color: white;
|
||||
border: 1px solid red;
|
||||
}
|
||||
25
tests_hugo/chat_nest/chat_server/.eslintrc.js
Normal file
25
tests_hugo/chat_nest/chat_server/.eslintrc.js
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
tsconfigRootDir : __dirname,
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:prettier/recommended',
|
||||
],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js'],
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
};
|
||||
4
tests_hugo/chat_nest/chat_server/.prettierrc
Normal file
4
tests_hugo/chat_nest/chat_server/.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
73
tests_hugo/chat_nest/chat_server/README.md
Normal file
73
tests_hugo/chat_nest/chat_server/README.md
Normal file
@@ -0,0 +1,73 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
3
tests_hugo/chat_nest/chat_server/dist/app.controller.d.ts
vendored
Normal file
3
tests_hugo/chat_nest/chat_server/dist/app.controller.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class AppController {
|
||||
place_holder(): void;
|
||||
}
|
||||
27
tests_hugo/chat_nest/chat_server/dist/app.controller.js
vendored
Normal file
27
tests_hugo/chat_nest/chat_server/dist/app.controller.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppController = class AppController {
|
||||
place_holder() { }
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "place_holder", null);
|
||||
AppController = __decorate([
|
||||
(0, common_1.Controller)()
|
||||
], AppController);
|
||||
exports.AppController = AppController;
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
1
tests_hugo/chat_nest/chat_server/dist/app.controller.js.map
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/app.controller.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AAG1C,IAAM,aAAa,GAAnB,MAAM,aAAa;IAExB,YAAY,KAAI,CAAC;CAClB,CAAA;AAFC;IAAC,IAAA,YAAG,GAAE;;;;iDACW;AAFN,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAGzB;AAHY,sCAAa"}
|
||||
2
tests_hugo/chat_nest/chat_server/dist/app.module.d.ts
vendored
Normal file
2
tests_hugo/chat_nest/chat_server/dist/app.module.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare class AppModule {
|
||||
}
|
||||
20
tests_hugo/chat_nest/chat_server/dist/app.module.js
vendored
Normal file
20
tests_hugo/chat_nest/chat_server/dist/app.module.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const chat_gateway_1 = require("./chat.gateway");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
providers: [chat_gateway_1.ChatGateway],
|
||||
})
|
||||
], AppModule);
|
||||
exports.AppModule = AppModule;
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
1
tests_hugo/chat_nest/chat_server/dist/app.module.js.map
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/app.module.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAKtC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,0BAAW,CAAC;KACzB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
3
tests_hugo/chat_nest/chat_server/dist/app.service.d.ts
vendored
Normal file
3
tests_hugo/chat_nest/chat_server/dist/app.service.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class AppService {
|
||||
getHello(): string;
|
||||
}
|
||||
20
tests_hugo/chat_nest/chat_server/dist/app.service.js
vendored
Normal file
20
tests_hugo/chat_nest/chat_server/dist/app.service.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppService = class AppService {
|
||||
getHello() {
|
||||
return 'Hello World!';
|
||||
}
|
||||
};
|
||||
AppService = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], AppService);
|
||||
exports.AppService = AppService;
|
||||
//# sourceMappingURL=app.service.js.map
|
||||
1
tests_hugo/chat_nest/chat_server/dist/app.service.js.map
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/app.service.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AAJY,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB;AAJY,gCAAU"}
|
||||
4
tests_hugo/chat_nest/chat_server/dist/chat.gateway.d.ts
vendored
Normal file
4
tests_hugo/chat_nest/chat_server/dist/chat.gateway.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare class ChatGateway {
|
||||
server: any;
|
||||
handleMessage(message: string): void;
|
||||
}
|
||||
43
tests_hugo/chat_nest/chat_server/dist/chat.gateway.js
vendored
Normal file
43
tests_hugo/chat_nest/chat_server/dist/chat.gateway.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"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.ChatGateway = void 0;
|
||||
const websockets_1 = require("@nestjs/websockets");
|
||||
let ChatGateway = class ChatGateway {
|
||||
handleMessage(message) {
|
||||
console.log("message received:");
|
||||
console.log(`[${message}]`);
|
||||
this.server.emit('message', message);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, websockets_1.WebSocketServer)(),
|
||||
__metadata("design:type", Object)
|
||||
], ChatGateway.prototype, "server", void 0);
|
||||
__decorate([
|
||||
(0, websockets_1.SubscribeMessage)('message'),
|
||||
__param(0, (0, websockets_1.MessageBody)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], ChatGateway.prototype, "handleMessage", null);
|
||||
ChatGateway = __decorate([
|
||||
(0, websockets_1.WebSocketGateway)({
|
||||
cors: {
|
||||
origin: '*',
|
||||
},
|
||||
})
|
||||
], ChatGateway);
|
||||
exports.ChatGateway = ChatGateway;
|
||||
//# sourceMappingURL=chat.gateway.js.map
|
||||
1
tests_hugo/chat_nest/chat_server/dist/chat.gateway.js.map
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/chat.gateway.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"chat.gateway.js","sourceRoot":"","sources":["../src/chat.gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAK4B;AAOrB,IAAM,WAAW,GAAjB,MAAM,WAAW;IAKvB,aAAa,CAAgB,OAAe;QAC3C,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACD,CAAA;AATA;IAAC,IAAA,4BAAe,GAAE;;2CACX;AAEP;IAAC,IAAA,6BAAgB,EAAC,SAAS,CAAC;IACb,WAAA,IAAA,wBAAW,GAAE,CAAA;;;;gDAI3B;AATW,WAAW;IALvB,IAAA,6BAAgB,EAAC;QACjB,IAAI,EAAE;YACL,MAAM,EAAE,GAAG;SACX;KACD,CAAC;GACW,WAAW,CAUvB;AAVY,kCAAW"}
|
||||
1
tests_hugo/chat_nest/chat_server/dist/main.d.ts
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/main.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
10
tests_hugo/chat_nest/chat_server/dist/main.js
vendored
Normal file
10
tests_hugo/chat_nest/chat_server/dist/main.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("@nestjs/core");
|
||||
const app_module_1 = require("./app.module");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
||||
1
tests_hugo/chat_nest/chat_server/dist/main.js.map
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/main.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
1
tests_hugo/chat_nest/chat_server/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
1
tests_hugo/chat_nest/chat_server/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
File diff suppressed because one or more lines are too long
5
tests_hugo/chat_nest/chat_server/nest-cli.json
Normal file
5
tests_hugo/chat_nest/chat_server/nest-cli.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
}
|
||||
14851
tests_hugo/chat_nest/chat_server/package-lock.json
generated
Normal file
14851
tests_hugo/chat_nest/chat_server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
74
tests_hugo/chat_nest/chat_server/package.json
Normal file
74
tests_hugo/chat_nest/chat_server/package.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "chat",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
"@nestjs/core": "^9.0.0",
|
||||
"@nestjs/platform-express": "^9.0.0",
|
||||
"@nestjs/platform-socket.io": "^9.2.0",
|
||||
"@nestjs/websockets": "^9.2.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.2.0",
|
||||
"socket.io": "^4.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^9.0.0",
|
||||
"@nestjs/schematics": "^9.0.0",
|
||||
"@nestjs/testing": "^9.0.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "28.1.8",
|
||||
"@types/node": "^16.0.0",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "28.1.3",
|
||||
"prettier": "^2.3.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "28.0.8",
|
||||
"ts-loader": "^9.2.3",
|
||||
"ts-node": "^10.0.0",
|
||||
"tsconfig-paths": "4.1.0",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
7
tests_hugo/chat_nest/chat_server/src/app.controller.ts
Normal file
7
tests_hugo/chat_nest/chat_server/src/app.controller.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@Get()
|
||||
place_holder() {}
|
||||
}
|
||||
7
tests_hugo/chat_nest/chat_server/src/app.module.ts
Normal file
7
tests_hugo/chat_nest/chat_server/src/app.module.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ChatGateway } from './chat.gateway';
|
||||
|
||||
@Module({
|
||||
providers: [ChatGateway],
|
||||
})
|
||||
export class AppModule {}
|
||||
24
tests_hugo/chat_nest/chat_server/src/chat.gateway.ts
Normal file
24
tests_hugo/chat_nest/chat_server/src/chat.gateway.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
WebSocketGateway,
|
||||
SubscribeMessage,
|
||||
WebSocketServer,
|
||||
MessageBody,
|
||||
} from '@nestjs/websockets';
|
||||
|
||||
@WebSocketGateway({
|
||||
cors: {
|
||||
origin: '*',
|
||||
},
|
||||
})
|
||||
export class ChatGateway {
|
||||
@WebSocketServer()
|
||||
server;
|
||||
|
||||
@SubscribeMessage('message')
|
||||
handleMessage(@MessageBody() message: string): void {
|
||||
console.log("message received:");
|
||||
console.log(`[${message}]`);
|
||||
this.server.emit('message', message);
|
||||
}
|
||||
}
|
||||
|
||||
8
tests_hugo/chat_nest/chat_server/src/main.ts
Normal file
8
tests_hugo/chat_nest/chat_server/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
24
tests_hugo/chat_nest/chat_server/test/app.e2e-spec.ts
Normal file
24
tests_hugo/chat_nest/chat_server/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
tests_hugo/chat_nest/chat_server/test/jest-e2e.json
Normal file
9
tests_hugo/chat_nest/chat_server/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
4
tests_hugo/chat_nest/chat_server/tsconfig.build.json
Normal file
4
tests_hugo/chat_nest/chat_server/tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
21
tests_hugo/chat_nest/chat_server/tsconfig.json
Normal file
21
tests_hugo/chat_nest/chat_server/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
}
|
||||
}
|
||||
22
tests_hugo/chat_nest_2/.eslintrc.js
Normal file
22
tests_hugo/chat_nest_2/.eslintrc.js
Normal file
@@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
tsconfigRootDir : __dirname,
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js'],
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
};
|
||||
4
tests_hugo/chat_nest_2/.prettierrc
Normal file
4
tests_hugo/chat_nest_2/.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
73
tests_hugo/chat_nest_2/README.md
Normal file
73
tests_hugo/chat_nest_2/README.md
Normal file
@@ -0,0 +1,73 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
3
tests_hugo/chat_nest_2/dist/app.controller.d.ts
vendored
Normal file
3
tests_hugo/chat_nest_2/dist/app.controller.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class AppController {
|
||||
getHello(): void;
|
||||
}
|
||||
27
tests_hugo/chat_nest_2/dist/app.controller.js
vendored
Normal file
27
tests_hugo/chat_nest_2/dist/app.controller.js
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppController = class AppController {
|
||||
getHello() { }
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AppController.prototype, "getHello", null);
|
||||
AppController = __decorate([
|
||||
(0, common_1.Controller)()
|
||||
], AppController);
|
||||
exports.AppController = AppController;
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
1
tests_hugo/chat_nest_2/dist/app.controller.js.map
vendored
Normal file
1
tests_hugo/chat_nest_2/dist/app.controller.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AAG1C,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGxB,QAAQ,KAAI,CAAC;CACd,CAAA;AAFC;IAAC,IAAA,YAAG,GAAE;;;;6CACO;AAHF,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAIzB;AAJY,sCAAa"}
|
||||
2
tests_hugo/chat_nest_2/dist/app.module.d.ts
vendored
Normal file
2
tests_hugo/chat_nest_2/dist/app.module.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare class AppModule {
|
||||
}
|
||||
22
tests_hugo/chat_nest_2/dist/app.module.js
vendored
Normal file
22
tests_hugo/chat_nest_2/dist/app.module.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const app_controller_1 = require("./app.controller");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [],
|
||||
controllers: [app_controller_1.AppController],
|
||||
providers: [],
|
||||
})
|
||||
], AppModule);
|
||||
exports.AppModule = AppModule;
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
1
tests_hugo/chat_nest_2/dist/app.module.js.map
vendored
Normal file
1
tests_hugo/chat_nest_2/dist/app.module.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AAO1C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IALrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
1
tests_hugo/chat_nest_2/dist/main.d.ts
vendored
Normal file
1
tests_hugo/chat_nest_2/dist/main.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
10
tests_hugo/chat_nest_2/dist/main.js
vendored
Normal file
10
tests_hugo/chat_nest_2/dist/main.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("@nestjs/core");
|
||||
const app_module_1 = require("./app.module");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
||||
await app.listen(8000);
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
||||
1
tests_hugo/chat_nest_2/dist/main.js.map
vendored
Normal file
1
tests_hugo/chat_nest_2/dist/main.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
1
tests_hugo/chat_nest_2/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
1
tests_hugo/chat_nest_2/dist/tsconfig.build.tsbuildinfo
vendored
Normal file
File diff suppressed because one or more lines are too long
5
tests_hugo/chat_nest_2/nest-cli.json
Normal file
5
tests_hugo/chat_nest_2/nest-cli.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
}
|
||||
14605
tests_hugo/chat_nest_2/package-lock.json
generated
Normal file
14605
tests_hugo/chat_nest_2/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
71
tests_hugo/chat_nest_2/package.json
Normal file
71
tests_hugo/chat_nest_2/package.json
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "chat_nest_2",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^9.0.0",
|
||||
"@nestjs/core": "^9.0.0",
|
||||
"@nestjs/platform-express": "^9.0.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^9.0.0",
|
||||
"@nestjs/schematics": "^9.0.0",
|
||||
"@nestjs/testing": "^9.0.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "28.1.8",
|
||||
"@types/node": "^16.0.0",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "28.1.3",
|
||||
"prettier": "^2.3.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "28.0.8",
|
||||
"ts-loader": "^9.2.3",
|
||||
"ts-node": "^10.0.0",
|
||||
"tsconfig-paths": "4.1.0",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
8
tests_hugo/chat_nest_2/src/app.controller.ts
Normal file
8
tests_hugo/chat_nest_2/src/app.controller.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
|
||||
@Get()
|
||||
getHello() {}
|
||||
}
|
||||
9
tests_hugo/chat_nest_2/src/app.module.ts
Normal file
9
tests_hugo/chat_nest_2/src/app.module.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [],
|
||||
})
|
||||
export class AppModule {}
|
||||
11
tests_hugo/chat_nest_2/src/main.ts
Normal file
11
tests_hugo/chat_nest_2/src/main.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
app.enableCors(options:{
|
||||
origin: ['http://localhost:3000']
|
||||
});
|
||||
await app.listen(8000);
|
||||
}
|
||||
bootstrap();
|
||||
24
tests_hugo/chat_nest_2/test/app.e2e-spec.ts
Normal file
24
tests_hugo/chat_nest_2/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
tests_hugo/chat_nest_2/test/jest-e2e.json
Normal file
9
tests_hugo/chat_nest_2/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
4
tests_hugo/chat_nest_2/tsconfig.build.json
Normal file
4
tests_hugo/chat_nest_2/tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
21
tests_hugo/chat_nest_2/tsconfig.json
Normal file
21
tests_hugo/chat_nest_2/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
}
|
||||
}
|
||||
54
tests_hugo/chat_node/README.md
Normal file
54
tests_hugo/chat_node/README.md
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
- [socket io multi room chat](http://psitsmike.com/2011/10/node-js-and-socket-io-multiroom-chat-tutorial/)
|
||||
|
||||
first time :
|
||||
npm install --save express socket.io cors
|
||||
sudo npm install -g nodemon
|
||||
|
||||
next time :
|
||||
npm install
|
||||
|
||||
anytime :
|
||||
nodemon server
|
||||
|
||||
- [ ] don't send message to oneself
|
||||
- [ ] create a room
|
||||
- [ ] automatically add someone to a room
|
||||
- [ ] being able to accept or refuse to be added to a room
|
||||
- [ ] what to do with message not received ?
|
||||
|
||||
```
|
||||
-> create_public_conv( room_name );
|
||||
-> create_private_conv( room_name );
|
||||
-> create_protected_conv( room_name );
|
||||
-> create_direct_conv( room_name );
|
||||
|
||||
-> change_conv( room_name );
|
||||
|
||||
-> get_conv_history( room_name );
|
||||
-> get_last_conv();
|
||||
|
||||
-> get_my_convs_directs( );
|
||||
-> get_my_convs_rooms( );
|
||||
-> get_public_convs( );
|
||||
|
||||
[ list ][ create ][ join ]
|
||||
"directs" . [direct] (public and protected)
|
||||
"rooms" . [room]
|
||||
. public
|
||||
. private
|
||||
. protected
|
||||
|
||||
on connection :
|
||||
get_convs_directs();
|
||||
get_convs_rooms();
|
||||
last_conv = get_last_conv();
|
||||
if (last_conv)
|
||||
get_conv_history(last_conv);
|
||||
|
||||
|
||||
```
|
||||
## todo:
|
||||
- check if drop down menu works also with buttons instead of <div tabindex=0>
|
||||
- add window for option when select 'room'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user