Skip to content
Merged
14 changes: 13 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@apphosting/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apphosting/common",
"version": "0.0.2",
"version": "0.0.3",
"description": "Shared library code for App Hosting framework adapters",
"author": {
"name": "Firebase",
Expand Down
58 changes: 58 additions & 0 deletions packages/@apphosting/common/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
import { spawn } from "child_process";

// Output bundle metadata specifications to be written to bundle.yaml
export interface OutputBundleConfigs {
version: "v1";
serverConfig: ServerConfig;
metadata: Metadata;
}

// Fields needed to configure the App Hosting server
interface ServerConfig {
// Command to start the server (e.g. ["node", "dist/index.js"]). Assume this command is run from the root dir of the workspace
runCommand: string[];
// Environment variables set when the app is run
environmentVariables?: EnvVarConfig[];
// The maximum number of concurrent requests that each server instance can receive.
// Defaults to 80.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to drop these defaults now that we know GCP can adjust default values per user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The defaults are set the same way the apphosting.yaml defaults are set. The comments are more just a fyi. Do they no longer apply? If not we should probably change the public docs too to reflect that https://firebase.google.com/docs/app-hosting/configure#configure-backend

Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we link to the product docs instead so we have a single source of truth?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the defaults in favor of linking the docs.

concurrency?: number;
// The number of CPUs used in a single server instance.
// Defaults to 1.
cpu?: "fractional" | 1 | 2 | 4 | 6 | 8;
// The amount of memory available for a server instance.
// Commonly one of: "256" | "512" | "1024" | "2048" | "4096" | "8192" | "16384"
// Defaults to 512MiB.
memoryMiB?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, we probably want number here too

// The limit on the minimum number of function instances that may coexist at a given time.
// Defaults to 0.
minInstances?: number;
// The limit on the maximum number of function instances that may coexist at a given time.
// Defaults to 100.
maxInstances?: number;
}

// Additonal fields needed for identifying the framework and adapter being used
interface Metadata {
// Name of the adapter (this should be the official package name) e.g. "@apphosting/adapter-nextjs"
adapterPackageName: string;
// Version of the adapter, e.g. "18.0.1"
adapterVersion?: string;
// Name of the framework that is being supported, e.g. "angular"
framework: string;
// Version of the framework that is being supported, e.g. "18.0.1"
frameworkVersion?: string;
}

// Represents a single environment variable.
interface EnvVarConfig {
// Name of the variable
variable: string;
// Value associated with the variable
value: string;
// Where the variable will be available, for now only RUNTIME is supported
availability: Availabilities.Runtime[];
}

// Represents where environment variables are available from
enum Availabilities {
Runtime,
}

// Options to configure the build of a framework application
export interface BuildOptions {
// command to run build script (e.g. "npm", "nx", etc.)
Expand Down
Loading