import { DeployBuilderOptions } from './actions' ; export const DEFAULT_NODE_VERSION = 14 ; export const DEFAULT_FUNCTION_NAME = 'ssr' ; const DEFAULT_FUNCTION_REGION = 'us-central1' ; const DEFAULT_RUNTIME_OPTIONS = { timeoutSeconds : 60 , memory : '1GB' } ; export const defaultPackage = ( dependencies , devDependencies , options , main ? ) => ( { name : 'functions' , description : 'Angular Universal Application' , main : main ?? 'index.js' , scripts : { start : main ? `node ${ main }` : 'firebase functions:shell' , } , engines : { node : ( options . functionsNodeVersion || DEFAULT_NODE_VERSION ) . toString ( ) } , dependencies , devDependencies , private : true } ) ; export const defaultFunction = ( path , options , functionName ) => `const functions = require('firebase-functions');

// Increase readability in Cloud Logging
require("firebase-functions/lib/logger/compat");

const expressApp = require('./${ path }/main').app();

exports.${ functionName || DEFAULT_FUNCTION_NAME } = functions
  .region('${ options . region || DEFAULT_FUNCTION_REGION }')
  .runWith(${ JSON . stringify ( options . functionsRuntimeOptions || DEFAULT_RUNTIME_OPTIONS ) })
  .https
  .onRequest(expressApp);
` ; export const dockerfile = ( options ) => `FROM node:${ options . functionsNodeVersion || DEFAULT_NODE_VERSION }-slim
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=production
COPY . ./
CMD [ "npm", "start" ]
` ;