Feature/backend server#1
Open
engbergandreas wants to merge 17 commits into
Open
Conversation
Uses an internal reciever buffer for each client connected that parses and consume messages in flight, even if they are split by the TCP socket
There was a problem hiding this comment.
Pull request overview
This PR introduces a rewritten Wormhole backend server for Astrocast, combining a TCP “wormhole” relay for OpenSpace peer sessions with an HTTP REST API for session management backed by Firebase.
Changes:
- Adds a new TCP message parser/router (
Wormhole) and session lifecycle manager (Session) to prevent dropped/coalesced TCP messages. - Introduces an Express-based REST API (
App) integrated with Firebase Admin for auth, session creation/removal, and statistics. - Establishes a TypeScript + ESLint/Prettier project setup and updates repo docs/ignores for local development.
Reviewed changes
Copilot reviewed 14 out of 18 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Adds TypeScript compiler configuration for building to dist/. |
| src/wormhole.ts | Implements TCP server, message framing/parsing, session routing, and authentication dispatch. |
| src/utils.ts | Adds lightweight logging helpers (debug/info/error) driven by env config. |
| src/types/types.ts | Defines protocol enums/types and session/statistics data types. |
| src/types/env.d.ts | Declares expected environment variables for Node.js typing. |
| src/session.ts | Implements per-session peer tracking, hostship logic, and message broadcast behavior. |
| src/index.ts | Adds server entrypoint wiring env config to app startup. |
| src/config/env.ts | Adds Zod-based environment validation and dotenv loading. |
| src/app.ts | Adds Express HTTP API endpoints and orchestrates Wormhole + DB session lifecycle. |
| src/adminFirebaseConfig.ts | Initializes Firebase Admin apps from service account JSON files. |
| src/adminApi.ts | Implements Firebase-backed admin/user auth and session CRUD/stat updates. |
| README.md | Updates setup/runtime documentation and protocol/message structure docs. |
| package.json | Defines Node/TS build/dev scripts and runtime/dev dependencies. |
| eslint.config.mjs | Adds ESLint config for TS + import sorting + Prettier compatibility. |
| .markdownlint.json | Adds Markdown linting configuration. |
| .gitignore | Ignores Firebase service account JSON patterns and build artifacts. |
| .env-sample | Provides a sample environment configuration for local setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Max paylaod size, try catch parsing payload messages - close connection if it fails, remove connection if we get unknown messageType
Comment on lines
+25
to
+44
| import { env } from './config/env'; | ||
|
|
||
| // Color codes for console logs | ||
| const FgRed = '\x1b[31m'; | ||
| const FgGreen = '\x1b[32m'; | ||
| const FgWhite = '\x1b[37m'; | ||
|
|
||
| /** | ||
| * Logs a debug info message if `DEBUG` flag is set to true. | ||
| * | ||
| * @param message The message to log | ||
| * @param params Any additional parameters to log | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export function LDEBUG(message: string, ...params: any[]): void { | ||
| if (env.DEBUG) { | ||
| // eslint-disable-next-line no-console | ||
| console.log(FgGreen, message, FgWhite, ...params); | ||
| } | ||
| } |
Comment on lines
+13
to
+16
| ADMIN_AUTH_SDK_FILEPATH: z.string(), | ||
| ADMIN_DB_SDK_FILEPATH: z.string(), | ||
| DATABASE_FIREBASE_DATABASE_URL: z.httpUrl() | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates and rewrites the backend server of the astrocast project
Fixes an issue where messages from OpenSpace would be dropped by the wormhole server
Major cleanup and some new api endpoints that will be used by the new frontend