Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit cf5e5db

Browse files
Support for Firebase 'Callable' functions #806
1 parent 03432cd commit cf5e5db

File tree

7 files changed

+179
-0
lines changed

7 files changed

+179
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ src/platforms/android/include.gradle
2626
!src/scripts/*.js
2727
!demo/karma.conf.js
2828
demo/*.d.ts
29+
demo/firebasefunctions/functions/lib
2930
!demo-push/karma.conf.js
3031
demo-push/*.d.ts
3132
demo-ng/*.d.ts

demo/firebasefunctions/.firebaserc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"projects": {
3+
"default": "n-plugin-test"
4+
}
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"functions": {
3+
"predeploy": [
4+
"npm --prefix \"$RESOURCE_DIR\" run lint",
5+
"npm --prefix \"$RESOURCE_DIR\" run build"
6+
]
7+
}
8+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "functions",
3+
"scripts": {
4+
"lint": "tslint --project tsconfig.json",
5+
"build": "tsc",
6+
"serve": "npm run build && firebase serve --only functions",
7+
"shell": "npm run build && firebase functions:shell",
8+
"start": "npm run shell",
9+
"deploy": "firebase deploy --only functions",
10+
"logs": "firebase functions:log"
11+
},
12+
"main": "lib/index.js",
13+
"dependencies": {
14+
"firebase-admin": "~6.0.0",
15+
"firebase-functions": "^2.0.3"
16+
},
17+
"devDependencies": {
18+
"tslint": "~5.8.0",
19+
"typescript": "~2.8.3"
20+
},
21+
"private": true
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as functions from "firebase-functions";
2+
3+
// // Start writing Firebase Functions
4+
// // https://firebase.google.com/docs/functions/typescript
5+
//
6+
export const helloWorld = functions.https.onRequest((request, response) => {
7+
response.send("Hello from Firebase!");
8+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["es6"],
4+
"module": "commonjs",
5+
"noImplicitReturns": true,
6+
"outDir": "lib",
7+
"sourceMap": true,
8+
"target": "es6"
9+
},
10+
"compileOnSave": true,
11+
"include": [
12+
"src"
13+
]
14+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"rules": {
3+
// -- Strict errors --
4+
// These lint rules are likely always a good idea.
5+
6+
// Force function overloads to be declared together. This ensures readers understand APIs.
7+
"adjacent-overload-signatures": true,
8+
9+
// Do not allow the subtle/obscure comma operator.
10+
"ban-comma-operator": true,
11+
12+
// Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules.
13+
"no-namespace": true,
14+
15+
// Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars.
16+
"no-parameter-reassignment": true,
17+
18+
// Force the use of ES6-style imports instead of /// <reference path=> imports.
19+
"no-reference": true,
20+
21+
// Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the
22+
// code currently being edited (they may be incorrectly handling a different type case that does not exist).
23+
"no-unnecessary-type-assertion": true,
24+
25+
// Disallow nonsensical label usage.
26+
"label-position": true,
27+
28+
// Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }.
29+
"no-conditional-assignment": true,
30+
31+
// Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed).
32+
"no-construct": true,
33+
34+
// Do not allow super() to be called twice in a constructor.
35+
"no-duplicate-super": true,
36+
37+
// Do not allow the same case to appear more than once in a switch block.
38+
"no-duplicate-switch-case": true,
39+
40+
// Do not allow a variable to be declared more than once in the same block. Consider function parameters in this
41+
// rule.
42+
"no-duplicate-variable": [true, "check-parameters"],
43+
44+
// Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should
45+
// instead use a separate variable name.
46+
"no-shadowed-variable": true,
47+
48+
// Empty blocks are almost never needed. Allow the one general exception: empty catch blocks.
49+
"no-empty": [true, "allow-empty-catch"],
50+
51+
// Functions must either be handled directly (e.g. with a catch() handler) or returned to another function.
52+
// This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on.
53+
"no-floating-promises": true,
54+
55+
// Do not allow any imports for modules that are not in package.json. These will almost certainly fail when
56+
// deployed.
57+
"no-implicit-dependencies": true,
58+
59+
// The 'this' keyword can only be used inside of classes.
60+
"no-invalid-this": true,
61+
62+
// Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead.
63+
"no-string-throw": true,
64+
65+
// Disallow control flow statements, such as return, continue, break, and throw in finally blocks.
66+
"no-unsafe-finally": true,
67+
68+
// Do not allow variables to be used before they are declared.
69+
"no-use-before-declare": true,
70+
71+
// Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid();
72+
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
73+
74+
// Disallow duplicate imports in the same file.
75+
"no-duplicate-imports": true,
76+
77+
78+
// -- Strong Warnings --
79+
// These rules should almost never be needed, but may be included due to legacy code.
80+
// They are left as a warning to avoid frustration with blocked deploys when the developer
81+
// understand the warning and wants to deploy anyway.
82+
83+
// Warn when an empty interface is defined. These are generally not useful.
84+
"no-empty-interface": {"severity": "warning"},
85+
86+
// Warn when an import will have side effects.
87+
"no-import-side-effect": {"severity": "warning"},
88+
89+
// Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for
90+
// most values and let for values that will change.
91+
"no-var-keyword": {"severity": "warning"},
92+
93+
// Prefer === and !== over == and !=. The latter operators support overloads that are often accidental.
94+
"triple-equals": {"severity": "warning"},
95+
96+
// Warn when using deprecated APIs.
97+
"deprecation": {"severity": "warning"},
98+
99+
// -- Light Warnigns --
100+
// These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info"
101+
// if TSLint supported such a level.
102+
103+
// prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array.
104+
// (Even better: check out utils like .map if transforming an array!)
105+
"prefer-for-of": {"severity": "warning"},
106+
107+
// Warns if function overloads could be unified into a single function with optional or rest parameters.
108+
"unified-signatures": {"severity": "warning"},
109+
110+
// Warns if code has an import or variable that is unused.
111+
"no-unused-variable": {"severity": "warning"},
112+
113+
// Prefer const for values that will not change. This better documents code.
114+
"prefer-const": {"severity": "warning"},
115+
116+
// Multi-line object liiterals and function calls should have a trailing comma. This helps avoid merge conflicts.
117+
"trailing-comma": {"severity": "warning"}
118+
},
119+
120+
"defaultSeverity": "error"
121+
}

0 commit comments

Comments
 (0)