Skip to content

Commit f3ed261

Browse files
authored
Firebase Functions ships with a binary (#1003)
We introduce a bin associated with the firebase-functions SDK! The binary exposes a simple server on localhost that describes the Firebase Functions defined in the current directory: ``` $ STACK_CONTROL_API_PORT=8181 npx firebase-functions # Optionally can pass in a FUNCTIONS_DIR as first arg Serving at port 8181 $ curl localhost:8181/__/stack.yaml | jq { "endpoints": { "onreqv2": { "platform": "gcfv2", "labels": {}, "httpsTrigger": {}, "entryPoint": "onreqv2" }, "onRequest": { "platform": "gcfv1", "httpsTrigger": {}, "entryPoint": "onRequest" } }, "specVersion": "v1alpha1", "requiredAPIs": [] } ```
1 parent 8e21f77 commit f3ed261

29 files changed

+872
-18
lines changed

.github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
- run: npm install
3232
- run: npm run lint
3333
- run: npm run format
34-
- run: npm run test
34+
- run: npm run build && npm run test

package-lock.json

+101-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
"lib"
2323
],
2424
"main": "lib/index.js",
25+
"bin": {
26+
"firebase-functions": "./lib/bin/firebase-functions.js"
27+
},
2528
"types": "lib/index.d.ts",
2629
"exports": {
2730
".": "./lib/index.js",
@@ -178,6 +181,7 @@
178181
"mz": "^2.7.0",
179182
"nock": "^10.0.6",
180183
"prettier": "^1.18.2",
184+
"semver": "^7.3.5",
181185
"sinon": "^7.3.2",
182186
"ts-node": "^8.3.0",
183187
"tslint": "^5.18.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const functions = require("../../../../src/index");
2+
3+
exports.groupedhttp = functions.https.onRequest((req, resp) => {
4+
resp.status(200).send("PASS");
5+
});
6+
7+
exports.groupedcallable = functions.https.onCall(() => {
8+
return "PASS";
9+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const functions = require("../../../../src/index");
2+
const functionsv2 = require("../../../../src/v2/index");
3+
4+
exports.v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
exports.v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
exports.v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
exports.v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
19+
20+
exports.g1 = require("./g1");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "commonjs-grouped"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const functions = require("../../../../src/index");
2+
const functionsv2 = require("../../../../src/v2/index");
3+
4+
exports.v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
exports.v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
exports.v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
exports.v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "commonjs-main",
3+
"main": "functions.js"
4+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const functions = require("../../../../src/index");
2+
const functionsv2 = require("../../../../src/v2/index");
3+
4+
exports.v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
exports.v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
exports.v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
exports.v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "commonjs"
3+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as functions from '../../../../lib/index.js';
2+
import * as functionsv2 from "../../../../lib/v2/index.js";
3+
4+
export const v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
export const v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
export const v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
export const v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "esm-ext",
3+
"main": "index.mjs"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as functions from "../../../../lib/index.js";
2+
import * as functionsv2 from "../../../../lib/v2/index.js";
3+
4+
export const v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
export const v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
export const v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
export const v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "esm-main",
3+
"main": "functions.js",
4+
"type": "module"
5+
}

spec/fixtures/sources/esm/index.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as functions from "../../../../lib/index.js";
2+
import * as functionsv2 from "../../../../lib/v2/index.js";
3+
4+
export const v1http = functions.https.onRequest((req, resp) => {
5+
resp.status(200).send("PASS");
6+
});
7+
8+
export const v1callable = functions.https.onCall(() => {
9+
return "PASS";
10+
});
11+
12+
export const v2http = functionsv2.https.onRequest((req, resp) => {
13+
resp.status(200).send("PASS");
14+
});
15+
16+
export const v2callable = functionsv2.https.onCall(() => {
17+
return "PASS";
18+
});
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "esm",
3+
"type": "module"
4+
}

0 commit comments

Comments
 (0)