From 53c81e4c446de73ba75164d877efc406b20cd599 Mon Sep 17 00:00:00 2001 From: osmait Date: Thu, 9 Nov 2023 13:26:16 -0400 Subject: [PATCH] deleting all prints --- CommentServices/main.py | 1 - FrontendRedSocial/red-social/LICENSE | 21 --- FrontendRedSocial/red-social/README.md | 4 +- .../app/components/Notification.tsx | 6 +- .../app/components/UnFollowButton.tsx | 10 +- .../red-social/app/services/AuthService.ts | 1 - .../red-social/app/services/post.services.ts | 18 ++- PostServices/post-service/docker-compose.yaml | 3 +- .../post-service/src/app.controller.ts | 4 +- .../src/post/controller/post.controller.ts | 4 - .../src/post/service/post.service.spec.ts | 2 +- .../src/post/service/post.service.ts | 1 - .../platform/server/handlers/handlers.go | 1 - .../internals/platform/utils/jwtDecode.go | 2 - .../controller/follower.controller.ts | 1 - notificationService/index.html | 2 +- .../platform/server/handlers/handler.go | 126 ------------------ .../internas/platform/server/server.go | 3 - .../platform/server/websocket/client.go | 4 - .../internas/platform/server/websocket/hub.go | 7 +- .../storage/rabbitMq/rabbitMQStore.go | 1 - .../internas/platform/utils/fetch.go | 2 - .../internas/service/notificationService.go | 2 - .../controller/UserController.java | 72 +++++----- 24 files changed, 54 insertions(+), 244 deletions(-) delete mode 100644 FrontendRedSocial/red-social/LICENSE delete mode 100644 notificationService/internas/platform/server/handlers/handler.go diff --git a/CommentServices/main.py b/CommentServices/main.py index fa6abd3..6e12c60 100644 --- a/CommentServices/main.py +++ b/CommentServices/main.py @@ -62,7 +62,6 @@ async def get_current_id( @app.get("/comment/{id}") async def getComment(id: str, current_user: Annotated[str, Security(get_current_id, scopes=["me"])]): - print(current_user) comments = comment_service.find_all_by_id(id) return comments diff --git a/FrontendRedSocial/red-social/LICENSE b/FrontendRedSocial/red-social/LICENSE deleted file mode 100644 index 7f91f84..0000000 --- a/FrontendRedSocial/red-social/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Next UI - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/FrontendRedSocial/red-social/README.md b/FrontendRedSocial/red-social/README.md index 38f323c..2b6d236 100644 --- a/FrontendRedSocial/red-social/README.md +++ b/FrontendRedSocial/red-social/README.md @@ -14,7 +14,6 @@ This is a template for creating applications using Next.js 13 (app directory) an ## How to Use - ### Use the template with create-next-app To create a new project based on this template using `create-next-app`, run the following command: @@ -37,4 +36,5 @@ npm run dev ## License -Licensed under the [MIT license](https://github.com/nextui-org/next-app-template/blob/main/LICENSE). \ No newline at end of file +Licensed under the [MIT license](https://github.com/nextui-org/next-app-template/blob/main/LICENSE). + diff --git a/FrontendRedSocial/red-social/app/components/Notification.tsx b/FrontendRedSocial/red-social/app/components/Notification.tsx index fcd8404..5c3fe64 100644 --- a/FrontendRedSocial/red-social/app/components/Notification.tsx +++ b/FrontendRedSocial/red-social/app/components/Notification.tsx @@ -5,15 +5,14 @@ import Link from "next/link"; import React, { useEffect } from "react"; import { useNotification } from "../store/state"; - export const Notification = () => { const notifications = useNotification((state) => state.messages); const setMessage = useNotification((state) => state.setMessages); const notificationLen = useNotification((state) => state.notificationLen); const setNotificationLen = useNotification( - (state) => state.setNotificationLen + (state) => state.setNotificationLen, ); - const user = useNotification(state => state.user) + const user = useNotification((state) => state.user); const reset = useNotification((state) => state.reset); @@ -25,7 +24,6 @@ export const Notification = () => { newSocket.onmessage = (event) => { const ms = JSON.parse(event.data); - console.log(event.data); setMessage(ms); }; diff --git a/FrontendRedSocial/red-social/app/components/UnFollowButton.tsx b/FrontendRedSocial/red-social/app/components/UnFollowButton.tsx index 031c11f..6afb5fd 100644 --- a/FrontendRedSocial/red-social/app/components/UnFollowButton.tsx +++ b/FrontendRedSocial/red-social/app/components/UnFollowButton.tsx @@ -8,20 +8,14 @@ type Props = { followRequest: followRequest; isFollow: boolean; setFollow: (b: boolean) => void; - }; -export const UnFollowButton = ({ - followRequest, - setFollow, -}: Props) => { +export const UnFollowButton = ({ followRequest, setFollow }: Props) => { const token = Cookies.get("x-token"); if (!token) { - throw new Error("Error Token Dont exist ") + throw new Error("Error Token Dont exist "); } - - console.log(followRequest); const handlerFollow = async () => { await unFollow(followRequest, token); setFollow(false); diff --git a/FrontendRedSocial/red-social/app/services/AuthService.ts b/FrontendRedSocial/red-social/app/services/AuthService.ts index d0fd8f8..f420c4a 100644 --- a/FrontendRedSocial/red-social/app/services/AuthService.ts +++ b/FrontendRedSocial/red-social/app/services/AuthService.ts @@ -11,7 +11,6 @@ export async function loginService(loginRequest: any) { try { const response = await fetch("http://localhost:8001/login", options); - console.log(response.status); const token = await response.json(); Cookies.set("x-token", token.token); } catch (error) { diff --git a/FrontendRedSocial/red-social/app/services/post.services.ts b/FrontendRedSocial/red-social/app/services/post.services.ts index 5621153..1f4055a 100644 --- a/FrontendRedSocial/red-social/app/services/post.services.ts +++ b/FrontendRedSocial/red-social/app/services/post.services.ts @@ -1,10 +1,7 @@ -import { cookies } from "next/headers"; import { CommentRequest, PostRequest, PostResponse } from "../../types"; - - export async function findMyProfilePost( - token: string + token: string, ): Promise { const options: any = { cache: "no-cache", @@ -14,7 +11,7 @@ export async function findMyProfilePost( }, }; - const response = await fetch('http://127.0.0.1:5000/api/post', options); + const response = await fetch("http://127.0.0.1:5000/api/post", options); const result = await response.json(); return result; @@ -22,7 +19,7 @@ export async function findMyProfilePost( export async function findPost( id: string, - token: string + token: string, ): Promise { const options: any = { cache: "no-cache", @@ -43,7 +40,6 @@ export async function findProfilePost( token: string, page: number, ): Promise { - console.log(id); const options: any = { cache: "no-cache", headers: { @@ -51,8 +47,10 @@ export async function findProfilePost( Authorization: `Bearer ${token}`, }, }; - console.log(page) - const response = await fetch(`http://127.0.0.1:5000/api/feed/${id}?page=${page}&limit=10`, options); + const response = await fetch( + `http://127.0.0.1:5000/api/feed/${id}?page=${page}&limit=10`, + options, + ); const result = await response.json(); @@ -95,7 +93,7 @@ export async function createComment(post: CommentRequest, token: string) { } export async function findOnePost( id: string, - token: string + token: string, ): Promise { const options: any = { cache: "no-cache", diff --git a/PostServices/post-service/docker-compose.yaml b/PostServices/post-service/docker-compose.yaml index 9262205..791d35c 100644 --- a/PostServices/post-service/docker-compose.yaml +++ b/PostServices/post-service/docker-compose.yaml @@ -16,7 +16,7 @@ services: build: context: . dockerfile: Dockerfile - + ports: - 3000:3000 depends_on: @@ -25,4 +25,3 @@ services: # - .:/app # - "/app/node_modules" command: npm run start:dev - diff --git a/PostServices/post-service/src/app.controller.ts b/PostServices/post-service/src/app.controller.ts index 4b205a6..cce879e 100644 --- a/PostServices/post-service/src/app.controller.ts +++ b/PostServices/post-service/src/app.controller.ts @@ -3,9 +3,7 @@ import { AppService } from './app.service'; @Controller() export class AppController { - constructor( - private readonly appService: AppService - ) { } + constructor(private readonly appService: AppService) {} @Get() getHello(): string { diff --git a/PostServices/post-service/src/post/controller/post.controller.ts b/PostServices/post-service/src/post/controller/post.controller.ts index 6ff013a..c2061bc 100644 --- a/PostServices/post-service/src/post/controller/post.controller.ts +++ b/PostServices/post-service/src/post/controller/post.controller.ts @@ -29,11 +29,7 @@ export class PostController { @Query('comment') comment: string, @Req() request: Request, ) { - console.log(comment); const token = request.headers['token']; - const userId = request.headers['user']; - console.log(token); - console.log(userId); if (!token) { throw new UnauthorizedException(); } diff --git a/PostServices/post-service/src/post/service/post.service.spec.ts b/PostServices/post-service/src/post/service/post.service.spec.ts index 7b3a0e3..eb7c457 100644 --- a/PostServices/post-service/src/post/service/post.service.spec.ts +++ b/PostServices/post-service/src/post/service/post.service.spec.ts @@ -155,7 +155,7 @@ describe('PostService', () => { config: undefined, }, isAxiosError: false, - toJSON: function(): object { + toJSON: function (): object { throw new Error('Function not implemented.'); }, }; diff --git a/PostServices/post-service/src/post/service/post.service.ts b/PostServices/post-service/src/post/service/post.service.ts index 0b25572..b4ad273 100644 --- a/PostServices/post-service/src/post/service/post.service.ts +++ b/PostServices/post-service/src/post/service/post.service.ts @@ -30,7 +30,6 @@ export class PostService { created(post: Post) { post.id = randomUUID(); - console.log(post); try { this.postRepository.save(post); diff --git a/apiGateway/internals/platform/server/handlers/handlers.go b/apiGateway/internals/platform/server/handlers/handlers.go index 71e6a68..af35f92 100644 --- a/apiGateway/internals/platform/server/handlers/handlers.go +++ b/apiGateway/internals/platform/server/handlers/handlers.go @@ -42,7 +42,6 @@ func GetProfile(c config.Config) gin.HandlerFunc { ctx.Status(http.StatusInternalServerError) return } - fmt.Println("aquiii") ctx.JSON(http.StatusOK, user) } diff --git a/apiGateway/internals/platform/utils/jwtDecode.go b/apiGateway/internals/platform/utils/jwtDecode.go index ae365f5..573f6aa 100644 --- a/apiGateway/internals/platform/utils/jwtDecode.go +++ b/apiGateway/internals/platform/utils/jwtDecode.go @@ -1,7 +1,6 @@ package utils import ( - "fmt" "strings" "github.com/gin-gonic/gin" @@ -16,7 +15,6 @@ type AppClaims struct { func DecodeJwt(c *gin.Context) (*jwt.Token, error) { tokeString := strings.TrimSpace(c.GetHeader("Authorization")) tokenClen := strings.Split(" ", tokeString) - fmt.Println(tokenClen) token, err := jwt.ParseWithClaims(tokenClen[1], AppClaims{}, func(token *jwt.Token) (interface{}, error) { return []byte("secret"), nil }) diff --git a/followersService/follower-service/src/follower/controller/follower.controller.ts b/followersService/follower-service/src/follower/controller/follower.controller.ts index 707dfb2..de8e7aa 100644 --- a/followersService/follower-service/src/follower/controller/follower.controller.ts +++ b/followersService/follower-service/src/follower/controller/follower.controller.ts @@ -8,7 +8,6 @@ export class FollowerController { @Post('follower/') public createdfollower(@Body() follower: Follower) { - console.log(follower); this.followerService.follow(follower); } diff --git a/notificationService/index.html b/notificationService/index.html index c415c4f..5466e31 100644 --- a/notificationService/index.html +++ b/notificationService/index.html @@ -1,4 +1,4 @@ - + diff --git a/notificationService/internas/platform/server/handlers/handler.go b/notificationService/internas/platform/server/handlers/handler.go deleted file mode 100644 index 2c0c908..0000000 --- a/notificationService/internas/platform/server/handlers/handler.go +++ /dev/null @@ -1,126 +0,0 @@ -package handlers - -import ( - "encoding/json" - "fmt" - "log" - "net/http" - - "github.com/gin-gonic/gin" - "github.com/gorilla/websocket" - "github.com/osmait/notificationservice/internas/service" -) - -func UnmarshalMessage(data []byte) (Message, error) { - var r Message - err := json.Unmarshal(data, &r) - return r, err -} - -func (r *Message) Marshal() ([]byte, error) { - return json.Marshal(r) -} - -type Message struct { - Pattern string `json:"pattern"` - Data any `json:"data"` -} - -type Data struct { - Content string `json:"content"` - UserID string `json:"userId"` - ID string `json:"id"` - Deleted bool `json:"deleted"` - CreatedAt string `json:"createdAt"` -} - -var upgrader = websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024, - CheckOrigin: func(r *http.Request) bool { - return true // Permitir todos los orĂ­genes - }, -} - -func Notification(notificationService service.NotificationService) gin.HandlerFunc { - return func(c *gin.Context) { - id := c.Param("id") - fmt.Println(id) - msgs := notificationService.GetMessages() - - socket, err := upgrader.Upgrade(c.Writer, c.Request, nil) - if err != nil { - log.Println(err) - c.JSON(http.StatusInternalServerError, "Error upgrading connection") - return - } - - var message Message - // client := NewClient(hub, socket) - - // hub.register <- client - for { - - for msg := range msgs { - - json.Unmarshal(msg.Body, &message) - fmt.Println(message.Pattern) - - if message.Pattern == "new-follow" { - if val, ok := message.Data.(map[string]interface{}); ok { - followingId, _ := val["followingId"] - - if followingId == id { - - socket.WriteMessage(websocket.TextMessage, msg.Body) - - // go hub.Broadcast(msg.Body, nil) - // go client.Write() - // return - - } - - } - - } - if message.Pattern == "new-post" { - - if val, ok := message.Data.(map[string]interface{}); ok { - fmt.Println(val) - post, _ := val["post"].(map[string]interface{}) - userId, _ := post["userId"].(string) - fmt.Println(userId) - - follower, _ := val["follower"].([]interface{}) - - followerSlice := make([]string, len(follower)) - for i, v := range follower { - followerSlice[i] = v.(string) - } - - if containsElement(followerSlice, id) { - - socket.WriteMessage(websocket.TextMessage, msg.Body) - // go hub.Broadcast(msg.Body, nil) - // go client.Write() - // return - } - - } - } - // fmt.Println(message) - } - } - } - -} -func containsElement(slice []string, element string) bool { - fmt.Println(slice) - fmt.Println(element) - for _, item := range slice { - if item == element { - return true - } - } - return false -} diff --git a/notificationService/internas/platform/server/server.go b/notificationService/internas/platform/server/server.go index 16b0bc1..233eff6 100644 --- a/notificationService/internas/platform/server/server.go +++ b/notificationService/internas/platform/server/server.go @@ -39,10 +39,7 @@ func New(ctx context.Context, host string, port uint, shutdownTimeout time.Durat func (s *Server) registerRoutes() { s.Engine.Use(cors.AllowAll()) - // s.Engine.Use(middleware.CheckAuthMiddleware()) - // s.Engine.GET("/ws/:id", handlers.Notification(s.notificationService)) - // s.Engine.GET("/ws/:id", s.Hub.HandleWebSocket(s.notificationService)) s.Engine.GET("/ws/:id", websocket.HandlerWs(s.Hub, s.notificationService)) } diff --git a/notificationService/internas/platform/server/websocket/client.go b/notificationService/internas/platform/server/websocket/client.go index c4a3ea3..1b66207 100644 --- a/notificationService/internas/platform/server/websocket/client.go +++ b/notificationService/internas/platform/server/websocket/client.go @@ -3,7 +3,6 @@ package websocket import ( "bytes" "encoding/json" - "fmt" "log" "net/http" "time" @@ -63,7 +62,6 @@ func handleNewFollow(message any, id string, msg []byte, c *Client) { c.conn.WriteMessage(websocket.CloseMessage, []byte{}) return } - fmt.Println(id) if follower.FollowingID == id { messageb := bytes.TrimSpace(bytes.Replace(msg, newline, space, -1)) c.hub.broadcast <- messageb @@ -112,7 +110,6 @@ func (c *Client) readPump(notificationservice service.NotificationService, id st for msg := range msgs { json.Unmarshal(msg.Body, &message) - fmt.Println("Probando") handler := patternHandlers[message.Pattern] handler(&message.Data, id, msg.Body, c) @@ -170,7 +167,6 @@ func HandlerWs(hub *Hub, notificationservice service.NotificationService) gin.Ha log.Println(err) return } - fmt.Println("aquii llegaste") client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)} client.hub.register <- client diff --git a/notificationService/internas/platform/server/websocket/hub.go b/notificationService/internas/platform/server/websocket/hub.go index 84f4ba7..a1d5745 100644 --- a/notificationService/internas/platform/server/websocket/hub.go +++ b/notificationService/internas/platform/server/websocket/hub.go @@ -1,9 +1,6 @@ package websocket -import ( - "fmt" - // "github.com/osmait/notificationservice/internas/service" -) +// "github.com/osmait/notificationservice/internas/service" type Message struct { Pattern string `json:"pattern"` @@ -65,8 +62,6 @@ func (h *Hub) Run() { } func containsElement(slice []string, element string) bool { - fmt.Println(slice) - fmt.Println(element) for _, item := range slice { if item == element { return true diff --git a/notificationService/internas/platform/storage/rabbitMq/rabbitMQStore.go b/notificationService/internas/platform/storage/rabbitMq/rabbitMQStore.go index f56d4f2..8bac32a 100644 --- a/notificationService/internas/platform/storage/rabbitMq/rabbitMQStore.go +++ b/notificationService/internas/platform/storage/rabbitMq/rabbitMQStore.go @@ -45,5 +45,4 @@ func (r RabbitMQEventStore) Consume() <-chan amqp.Delivery { log.Fatal(err) } return msgs - } diff --git a/notificationService/internas/platform/utils/fetch.go b/notificationService/internas/platform/utils/fetch.go index 8186a25..c73bf39 100644 --- a/notificationService/internas/platform/utils/fetch.go +++ b/notificationService/internas/platform/utils/fetch.go @@ -20,13 +20,11 @@ func Fetch(url string) ([]byte, error) { resp, err := client.Do(req) if err != nil || resp.StatusCode != 200 { - return nil, errors.New("Internal Error with Request") } body, err := io.ReadAll(resp.Body) if err != nil { - return nil, err } diff --git a/notificationService/internas/service/notificationService.go b/notificationService/internas/service/notificationService.go index b20bfc2..be31e9d 100644 --- a/notificationService/internas/service/notificationService.go +++ b/notificationService/internas/service/notificationService.go @@ -13,10 +13,8 @@ func NewNotificationService(rabbirMqStore rabbitmq.RabbitMQEventStore) *Notifica return &NotificationService{ rabbitMqStore: rabbirMqStore, } - } func (n *NotificationService) GetMessages() <-chan amqp.Delivery { return n.rabbitMqStore.Consume() - } diff --git a/userService/userService/src/main/java/com/sbsocial/userservice/infraestruture/controller/UserController.java b/userService/userService/src/main/java/com/sbsocial/userservice/infraestruture/controller/UserController.java index fca5e08..1175d5c 100644 --- a/userService/userService/src/main/java/com/sbsocial/userservice/infraestruture/controller/UserController.java +++ b/userService/userService/src/main/java/com/sbsocial/userservice/infraestruture/controller/UserController.java @@ -18,43 +18,41 @@ @RequiredArgsConstructor public class UserController { - final private UserServices userServices; - - - @GetMapping("/{id}") - public ResponseEntity getUser(@PathVariable("id")UUID id){ - User user = userServices.findOne(id); - return new ResponseEntity<>(user,HttpStatus.OK); - } - - @PostMapping - public ResponseEntity postUser(@RequestBody UserDto userRequest ){ - userServices.create(userRequest); - return new ResponseEntity<>("Created",HttpStatus.CREATED); - } - - @GetMapping("/email") - public ResponseEntity getUserByEmail(@RequestParam("email")String email){ - if (email == null){ - throw new RuntimeException("Error Email Is required"); - } - User user = userServices.findOneByEmail(email); - return new ResponseEntity<>(user,HttpStatus.OK); + final private UserServices userServices; + + @GetMapping("/{id}") + public ResponseEntity getUser(@PathVariable("id") UUID id) { + User user = userServices.findOne(id); + return new ResponseEntity<>(user, HttpStatus.OK); + } + + @PostMapping + public ResponseEntity postUser(@RequestBody UserDto userRequest) { + userServices.create(userRequest); + return new ResponseEntity<>("Created", HttpStatus.CREATED); + } + + @GetMapping("/email") + public ResponseEntity getUserByEmail(@RequestParam("email") String email) { + if (email == null) { + throw new RuntimeException("Error Email Is required"); } - - @CrossOrigin - @GetMapping("/profile/{id}") - public ResponseEntityProfile(@PathVariable("id") UUID id){ - UserResponse user = userServices.findProfile(id); - return new ResponseEntity<>(user,HttpStatus.OK); - } - - @CrossOrigin - @GetMapping("/find") - public ResponseEntity>FindUsersByName(@RequestParam("name") String name ){ - List list =userServices.findUsersByName(name); - return new ResponseEntity<>(list,HttpStatus.OK); - } - + User user = userServices.findOneByEmail(email); + return new ResponseEntity<>(user, HttpStatus.OK); + } + + @CrossOrigin + @GetMapping("/profile/{id}") + public ResponseEntity Profile(@PathVariable("id") UUID id) { + UserResponse user = userServices.findProfile(id); + return new ResponseEntity<>(user, HttpStatus.OK); + } + + @CrossOrigin + @GetMapping("/find") + public ResponseEntity> FindUsersByName(@RequestParam("name") String name) { + List list = userServices.findUsersByName(name); + return new ResponseEntity<>(list, HttpStatus.OK); + } }