Skip to content

1tzArad/PixelMessager-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Important

This project has been discontinued and is no longer being actively worked on. Since the project has been abandoned, I've decided to make my contribution open source.

It's also worth noting that this project was never truly completed. There is still a significant amount of work required for it to be considered finished, and many planned features and improvements were never implemented.

The front-end source code is available here: PixelMessager Frontend.

I also no longer actively work with TypeScript/JavaScript.

PixelMessenger Backend API

This document describes all backend endpoints, authentication, and data structures for PixelMessenger.


Table of Contents


Getting Started

  1. Install dependencies:

    npm install
  2. Configure environment variables:
    Copy .env.example to .env and fill in the required values.

  3. Run in development:

    npm run dev:watch
  4. Build for production:

    npm run build
    npm start

Authentication

  • All protected endpoints require a JWT token in the Authorization header:
    Authorization: Bearer <token>
    
  • Socket connections require a JWT token in the auth payload.

API Endpoints

User

GET /users

Returns a list of all users.

Response Example:

[
  {
    "id": "fd7ecb69-c413-4d82-b5c6-a66cabf50c48",
    "username": "testuser",
    "email": "test@example.com",
    "password": "hashed_password",
    "createdAt": "2025-06-21T22:02:38.925Z"
  }
]

POST /users/register

Register a new user.

Request Body:

{
  "username": "string",
  "email": "string",
  "password": "string"
}

Response:

  • If email or username exists:
    { "text": "Email or Username already exists!" }
  • On success:
    { "text": "Account Created!", "token": "jwt_token" }

Direct Chat

GET /direct-chat/list

Get a list of direct chats for the authenticated user.

Headers:
Authorization: Bearer <token>

Response Example:

[
  {
    "id": "chat_id",
    "type": "DIRECT",
    "participants": [
      {
        "id": "participant_id",
        "user": {
          "uuid": "user_uuid",
          "username": "username",
          "email": "email"
        },
        "publicKey": "public_key",
        "encryptedPrivateKey": "encrypted_private_key",
        "joinedAt": "timestamp"
      }
    ],
    "name": "OtherUserName",
    "createdAt": "timestamp"
  }
]

Messages

GET /messages

Returns all global chat messages.

Response Example:

[
  {
    "id": "803c0c2b-926c-40bb-80a1-4b46041da246",
    "sendedById": 1,
    "sendedByUsername": "Arad",
    "message": "hello",
    "receiverId": null,
    "inGlobalChat": true,
    "timestamp": "123123123123"
  }
]

POST /messages/:dmId

Get messages for a specific direct message (DM) chat.

Request Body:

{ "userId": number }

Params:
dmId: number

Response:
Same as /messages endpoint.


Socket Events

message

Send or receive a chat message.

Payload:

{
  chat: Chat;
  content: string;
}

direct-create

Create a new direct chat.

Payload:

{
  publicKey: string;
  receiver: User;
  encryptedPrivateKey: string;
}

Entities

User

{
  uuid: string;
  username: string;
  email: string;
  password: string;
  createdAt: string;
}

Chat

{
  id: string;
  type: "DIRECT" | "GROUP" | "GLOBAL";
  participants: ChatParticipant[];
  name?: string;
  message?: Message[];
  createdAt: string;
}

ChatParticipant

{
  id: string;
  chat: Chat;
  user: User;
  publicKey: string;
  encryptedPrivateKey?: string;
  joinedAt: string;
}

Message

{
  id: string;
  chat: Chat;
  sender: User;
  content: string;
  createdAt: string;
}

Environment Variables

See .env.example for required variables:

  • JWT_SECRET – JWT signing key
  • DB_TYPE – Database type (e.g., postgres)
  • DB_URL – Database connection URL

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages