Categorygithub.com/Edigiraldo/RestWebSockets
repositorypackage
0.0.0-20230114160228-9dbafa9cee82
Repository: https://github.com/edigiraldo/restwebsockets.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Web forum with REST and WebSockets

This project consists of an API for a simple web forum that allows users to create, update, delete and list posts. Users can create an account and login within the site. In addition, they can open a websocket connection to get notified of any new posts. Finally, users can see their own information.

The project consists on a service that is facing user's request. The data is backed up in a Postgres DB, the authentication system uses JSON web tokens, and HTTP and websocket protocols are used.

Instructions

To run this proyect in your local environment:

  • Go to the root of the proyect and then
    docker-compose up -d --build

Locally:

  • To sing up:

    [POST] localhost:5050/api/v1/signup

    {
      "email": "[email protected]",
      "password": "yourpassword"
    }
    
  • To login and get a token:

    [POST] localhost:5050/api/v1/login

    {
      "email": "[email protected]",
      "password": "yourpassword"
    }
    
  • To open a websocket connection:

    WS

    localhost:5050/api/v1/ws

    Header

    {
      "Authorization": "the.received.token"
    }
    
  • To Get user info:

    User info

    [GET] localhost:5050/api/v1/me

    Header

    {
      "Authorization": "the.received.token"
    }
    
  • To create a new post:

    Create post

    [POST] localhost:5050/api/v1/posts

    Header

    {
      "Authorization": "the.received.token"
    }
    

    Body

    {
      "content": "The post content"
    }
    
  • To get a post:

    Get post

    [GET] localhost:5050/api/v1/posts/{post_id}

    Header

    {
      "Authorization": "the.received.token"
    }
    
  • To update the content of a post:

    Update post

    [PATCH] localhost:5050/api/v1/posts/{post_id}

    Header

    {
      "Authorization": "the.received.token"
    }
    

    Body

    {
      "content": "The new post content"
    }
    
  • To delete a post:

    Delete post

    [DELETE] localhost:5050/api/v1/posts/{post_id}

    Header

    {
      "Authorization": "the.received.token"
    }