Skip to content

Feature/backend server#1

Open
engbergandreas wants to merge 17 commits into
masterfrom
feature/backend-server
Open

Feature/backend server#1
engbergandreas wants to merge 17 commits into
masterfrom
feature/backend-server

Conversation

@engbergandreas

Copy link
Copy Markdown
Member

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/wormhole.ts Outdated
Comment thread src/wormhole.ts
Comment thread src/wormhole.ts
Comment thread src/session.ts
Comment thread src/app.ts
Comment thread package.json Outdated
Comment thread eslint.config.mjs
Comment thread README.md Outdated
Comment thread src/wormhole.ts Outdated
Comment thread src/session.ts Outdated
Max paylaod size, try catch parsing payload messages - close connection if it fails, remove connection if we get unknown messageType

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 18 changed files in this pull request and generated 8 comments.

Comment thread src/wormhole.ts
Comment thread src/session.ts
Comment thread src/session.ts
Comment thread src/session.ts
Comment thread src/utils.ts
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 thread src/config/env.ts
Comment on lines +13 to +16
ADMIN_AUTH_SDK_FILEPATH: z.string(),
ADMIN_DB_SDK_FILEPATH: z.string(),
DATABASE_FIREBASE_DATABASE_URL: z.httpUrl()
});
Comment thread src/adminApi.ts
Comment thread src/session.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants