Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

Local sync project

Simple Bun + Express + Angular server and client, to sync text, image and files using messages.

Motivation

This is a specific, but simple project which aims to quickly allow passing text, files and images between two or more local network computers, but primarily images, as it I'm not able to sync image clipboard using remote desktop apps.

I also wanted to make sure that any text and file should be deleted whenever the server shutdowns or restarts, and be able to run the server locally to have a faster file transfer than a hosted service.

Requirements

  • The app must be able to send text, image and files between two or more computers in the same network;
  • The app must be able to paste images from the clipboard and send it;
  • Text and images can be copied to the clipboard;
  • No file size limit, but can still be enforced via frontend file validation code;
  • Any client can send to any other client, but no information of specific client who sent the message is kept;
  • Any message and files stored in the server must be deleted whenever the server restarts.

Backend

Made using Typescript, Express and zod for schema validation.

All messages are stored in-memory, meaning that when the server shutdowns, all messages are lost, no persistence features are implemented.

The server stores the files at "upload/" folder, whenever the server restarts, this folder is cleaned up, as any information of file IDs and the filename also aren't persisted.

It also serves a WebSocket to notify clients that a new message arrived.

API

POST /message-send/text

Returns the new message's ID.

Sends a simple text message with plain text message of the request as it's content.

POST /message-send/file

Usage:

{
	fileId: `${string}-${string}-${string}-${string}-${string}`, // UUID string
	text: string
}

Returns the new message's ID.

Sends a message with a file attachment identified by fileId, and the text content on text.

GET /message/:id

Gets a message object identified by :id parameter, being it a UUIDv4 string.

POST /messages

Usage:

{
	pageSize?: number, // positive integer, defaults to `10`
	pageNumber?: number, // positive integer, defaults to `1`
	all?: number // defaults to `false`
}

List messages with pagination. If all is true, it returns all the messages in a single page.

GET /file/:id

Gets a file content identified by :id parameter, being it a UUIDv4 string.

GET /file-download/:id

Downloads a file content identified by :id parameter, being it a UUIDv4 string.

POST /file-upload

Returns the new file's ID.

Uploads a file to the server, using multipart form, with the file in file key.

WebSocket

Connecting to the websocket, the clients can receive a message with the following payload:

{
	type: "newMessage",
	messageId: `${string}-${string}-${string}-${string}-${string}` // UUID string
}

This message is sent any time other clients sends a new text, image or file message.

Frontend

Made in Typescript and Angular, it contains a simple interface with a message box on bottom, allowing to type a text, attach files and send the message, a list of all the messages and a list of toast notifications.

alt text alt text alt text

SSL

For the server to run on https, it expects a key and certificate file paths as environment variables, on SSL_KEY and SSL_CERT keys, respectively.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages