Deployment

Deploying your Jetpath application involves packaging your code and dependencies, choosing a hosting environment, and running the application server so it’s accessible to users. Jetpath’s flexibility allows you to deploy it across various platforms using Node.js, Deno, or Bun as the runtime.


General Considerations Before Deployment

Regardless of your target platform, consider these points:

  1. Build Step (TypeScript Compilation):

    • Jetpath applications are typically written in TypeScript (.jet.ts, .ts).
    • Node.js/Bun (often): You’ll usually need to compile your TypeScript code to JavaScript using tsc (based on your tsconfig.json) or Bun’s built-in bundler/transpiler before deployment. Your server.ts entry point will then run the compiled JavaScript output (e.g., node dist/server.js).
    • Deno: Deno can run TypeScript directly. You might still have a build step for bundling or type checking (deno check server.ts), but compilation to JS isn’t strictly necessary for running.
    • Ensure your build output includes all necessary JavaScript files.
  2. Dependencies:

    • Node.js/Bun: Your node_modules directory (containing dependencies listed in package.json) must be included in the deployment or installed on the target server using npm install --production, yarn install --production, or bun install --production.
    • Deno: Dependencies are typically cached based on imports. Ensure the deployment environment has network access to download dependencies on first run, or use deno vendor to vendor dependencies locally before deployment.
  3. Runtime Choice:

    • Ensure the exact runtime (Node.js, Deno, or Bun) and version you developed with is installed and available in your deployment environment (VM, container image, PaaS setting).
  4. Environment Variables:

    • Never hardcode secrets (API keys, database passwords, JWT secrets) in your code.
    • Use environment variables (process.env.VARIABLE_NAME) to manage configuration.
    • Most hosting platforms provide a way to securely set environment variables for your application. Consult your platform’s documentation.
  5. Port Binding:

    • Your Jetpath application listens on a port specified in the Jetpath constructor (port: 3000) or potentially via an environment variable (e.g., process.env.PORT).
    • Most hosting platforms (PaaS, Containers) automatically route external traffic (on port 80/443) to the port your application listens on internally. Ensure your application respects the PORT environment variable if provided by the platform.
  6. Static Files:

    • If your application serves static files (CSS, JS, images) using Jetpath’s static option, ensure these files are included in your deployment package and the paths are configured correctly. Often, it’s more performant to serve static files directly via a reverse proxy (like Nginx) or a CDN.

Common Deployment Strategies

Here are outlines for common deployment approaches:

1. Virtual Machines (VMs) / Bare Metal

2. Containers (Docker)

3. Platform-as-a-Service (PaaS)

4. Serverless Functions


Jetpath Specifics & Recommendations


Next Steps