GithubHelp home page GithubHelp logo

benjamingb / okku-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from estebanborai/okku-server

0.0 1.0 0.0 3.37 MB

Back-End for Okku realtime chat solution. All the logic related to Okku's features are handled through this server. An instance of this server handles user authentication, media management, chat history as well as connections

License: Other

Rust 93.70% Shell 0.86% Dockerfile 0.06% HTML 0.66% TypeScript 4.31% JavaScript 0.41%

okku-server's Introduction

okku-server

Back-End for Okku realtime chat solution. All the logic related to Okku's features are handled through this server. An instance of this server handles user authentication, media management, chat history as well as connections

Index

Architecture

Front-End

The Okku CLI offers a terminal based interface for sending and receiving text messages.

Getting Started

For development purposes you require Rust installed in your system and Docker with docker-compose as well.

It's recomended to install Rust using rustup.rs solution.

Environment Variables

Environment variables specified on .env.sample file are required by both, the database and the server.

Create a .env file with a copy of the contents available on the .env.sample file and fill the relevant values.

Please make sure you have a .env file ready before going any further

Database

The PostgreSQL database must be running in order for the server to run. Please issue the following command:

docker volume create --name okku-database && docker-compose up --build

Source

This command will create a new volume to store database files with the name okku-database. And then will run docker-compose up --build using the docker-compose.yml file available in the project's root directory.

Server

In order to run the server you must issue:

cargo run

API Endpoints

Name Description Method URI HTTP Headers HTTP Req. Body HTTP Res. Body
Login Authenticates an existing user and retrieves a JWT token GET /api/v1/auth/login
  • "Authorization: Basic {Base64(user_id:password)}"
N/A { "token": ":JWT Token" }
Me Retrieve Profile and User details for the authenticated user GET /api/v1/auth/me
  • "Authorization: Bearer {Token}"
N/A { "user": { "id": "52933f2f-2a2f-4942-8398-a8aee83569c6", "name": "foo" }, "profile": { "id": "0bc1eefd-6dd1-48dc-be2d-73c94ba7f984", "first_name": null, "email": "[email protected]", "avatar": null, "surname": null, "birthday": null, "contacts": null, "bio": null } }
Sign Up Registers a new user and retrieves a token POST /api/v1/auth/signup N/A { "name": "foobar", "password": "root", "email": "[email protected]" } { "token": ":Token", "user": { "id": "705c0c8f-9fc7-424d-a9c7-edc9df9146e0", "name": "foobar" } }
Find User Chats Retrive authenticated user chats GET /api/v1/chats
  • "Authorization: Bearer {Token}"
N/A { "chats": [ { "id": "10c941f5-f2cc-4f74-890b-34ad5c24fadd", "participants_ids": [ "56851552-eb2b-478b-8401-4abcd6754380", "52933f2f-2a2f-4942-8398-a8aee83569c6" ] } ] }
Fetch Chat Messages Retrieve chat's message history GET /api/v1/chats/:chat_id/messages
  • "Authorization: Bearer {Token}"
N/A { "messages": [ { "id": "9fee900b-d92e-4e1e-ad35-b2593a7a53cb", "body": "Hello world!", "chat": { "id": "10c941f5-f2cc-4f74-890b-34ad5c24fadd", "participants_ids": [ "56851552-eb2b-478b-8401-4abcd6754380", "52933f2f-2a2f-4942-8398-a8aee83569c6" ] }, "author": { "id": "56851552-eb2b-478b-8401-4abcd6754380", "name": "foobar" }, "created_at": "2021-02-13T02:12:39.235418Z" } ] }
Create Chat Creates a new chat and specify its participants POST /api/v1/chats
  • "Authorization: Bearer {Token}"
{ "participants_ids": [ "56851552-eb2b-478b-8401-4abcd6754380", "52933f2f-2a2f-4942-8398-a8aee83569c6" ] } { "id": "10c941f5-f2cc-4f74-890b-34ad5c24fadd", "messages": [], "participants_ids": [ "56851552-eb2b-478b-8401-4abcd6754380", "52933f2f-2a2f-4942-8398-a8aee83569c6" ] }

About deprecated endpoints

If you look closely to domain directory, you will notice that theres logic available for more features which is not exposed to the API.

These logic includes file management and profile details which used to be part of a release of this server on a Web Application.

Those features are now deprecated in order to focus on main functionality before going any further.

This project is part of my learning journey with Rust and implementing this features helped me understand more how the language works and what it has to offer.

If you are interested on working on some of these features, from the server side or the client side, feel free to reach me via an issue I will be happy to help!

License

This project is licensed under the MIT license

Contributions

All contributions are welcome! Feel free to open a pull request or an issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.