diff --git a/scripts/bin-test/test.ts b/scripts/bin-test/test.ts index 1c6f1a24e..0ce2f6518 100644 --- a/scripts/bin-test/test.ts +++ b/scripts/bin-test/test.ts @@ -85,7 +85,8 @@ async function startBin( env: { PATH: process.env.PATH, GLCOUD_PROJECT: 'test-project', - STACK_CONTROL_API_PORT: port, + PORT: port, + FUNCTIONS_CONTROL_API: 'true', }, }); @@ -95,7 +96,7 @@ async function startBin( await retryUntil(async () => { try { - await fetch(`http://localhost:${port}/__/stack.yaml`); + await fetch(`http://localhost:${port}/__/functions.yaml`); } catch (e) { if (e?.code === 'ECONNREFUSED') { return false; @@ -132,7 +133,7 @@ async function startBin( }; } -describe('stack.yaml', () => { +describe('functions.yaml', () => { async function runTests(tc: Testcase) { let port: number; let cleanup: () => Promise; @@ -147,14 +148,14 @@ describe('stack.yaml', () => { await cleanup?.(); }); - it('stack.yaml returns expected Manifest', async () => { - const res = await fetch(`http://localhost:${port}/__/stack.yaml`); + it('functions.yaml returns expected Manifest', async () => { + const res = await fetch(`http://localhost:${port}/__/functions.yaml`); const text = await res.text(); let parsed: any; try { parsed = yaml.load(text); } catch (err) { - throw new Error('Failed to parse stack.yaml ' + err); + throw new Error('Failed to parse functions.yaml ' + err); } expect(parsed).to.be.deep.equal(tc.expected); }); diff --git a/src/bin/firebase-functions.ts b/src/bin/firebase-functions.ts index 597819658..4b4eba900 100644 --- a/src/bin/firebase-functions.ts +++ b/src/bin/firebase-functions.ts @@ -35,21 +35,24 @@ async function handleQuitquitquit(req: express.Request, res: express.Response) { app.get('/__/quitquitquit', handleQuitquitquit); app.post('/__/quitquitquit', handleQuitquitquit); -app.get('/__/stack.yaml', async (req, res) => { - try { - const stack = await loadStack(functionsDir); - res.setHeader('content-type', 'text/yaml'); - res.send(JSON.stringify(stack)); - } catch (e) { - res - .status(400) - .send(`Failed to generate manifest from function source: ${e}`); - } -}); + +if (process.env.FUNCTIONS_CONTROL_API === 'true') { + app.get('/__/functions.yaml', async (req, res) => { + try { + const stack = await loadStack(functionsDir); + res.setHeader('content-type', 'text/yaml'); + res.send(JSON.stringify(stack)); + } catch (e) { + res + .status(400) + .send(`Failed to generate manifest from function source: ${e}`); + } + }); +} let port = 8080; -if (process.env.STACK_CONTROL_API_PORT) { - port = Number.parseInt(process.env.STACK_CONTROL_API_PORT); +if (process.env.PORT) { + port = Number.parseInt(process.env.PORT); } console.log('Serving at port', port); diff --git a/src/runtime/loader.ts b/src/runtime/loader.ts index f9ba05652..8d08138b9 100644 --- a/src/runtime/loader.ts +++ b/src/runtime/loader.ts @@ -110,10 +110,9 @@ export async function loadStack(functionsDir: string): Promise { extractStack(mod, endpoints, requiredAPIs); - const stack: ManifestStack = { + return { endpoints, specVersion: 'v1alpha1', requiredAPIs: mergeRequiredAPIs(requiredAPIs), }; - return stack; }