Skip to content

Add a standalone HTTP listener for non-serverless deployments #2

Description

@XCraftTM

Problem

The project cannot run as a standalone Node.js service because api/index.js creates and exports the Express application but never starts an HTTP listener.

package.json defines the start command as:

node api/index.js

However, api/index.js ends by exporting the app without calling app.listen(...). In a regular Node/Pterodactyl-style container, the process therefore exits after module initialization instead of staying alive to serve requests. The current export-only behavior is appropriate for serverless deployments such as Vercel, but it prevents self-hosted deployments from starting.

Expected behavior

Running npm start should keep the process running and accept HTTP requests on the port supplied through process.env.PORT.

Suggested change

Start the server only when the module is executed directly, while retaining the export for serverless use:

if (require.main === module) {
  app.listen(PORT, "0.0.0.0", () => {
    console.log(`API listening on port ${PORT}`);
  });
}

module.exports = app;

Binding to 0.0.0.0 allows the service to be reachable through container networking. The require.main guard preserves compatibility with platforms that import api/index.js as a handler.

Acceptance criteria

  • npm start keeps the Node.js process alive.
  • The service listens on process.env.PORT (falling back to the existing default of 3000).
  • The application binds to 0.0.0.0 for container hosting.
  • module.exports = app remains available for Vercel/serverless deployments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions