-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Support useEmulators, more DI, and FCM fixes (#2652)
* Adding `USE_EMULATOR` to auth, database, firestore, and functions * Adding `VAPID_KEY` and `SERVICE_WORKER` DI tokens to messaging * Adding `SETTINGS`, `TENANT_ID`, `LANGUAGE_CODE`, `USE_DEVICE_LANGUAGE`, and `PERSISTENCE` DI tokens to auth * Adding `NEW_ORIGIN_BEHAVIOR` DI token to functions, to opt-into the new way of setting `ORIGIN` * Adding `MAX_UPLOAD_RETRY_TIME` and `MAX_OPERATION_RETRY_TIME` DI tokens to storage * `tokenChanges` will now listen for notification permission changes and trip token detection as expected * `httpsCallable` function now takes in `HttpsCallableOptions` * `deleteToken`'s token argument is now optional, reflecting Firebase v8 changes * Firestore snapshots now include metadata by default
- Loading branch information
1 parent
6c2473a
commit 8d3093f
Showing
32 changed files
with
534 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,8 @@ | |
] | ||
} | ||
} | ||
}, | ||
"projects": { | ||
"default": "aftest-94085" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
"plugin:import/errors", | ||
"plugin:import/warnings", | ||
"plugin:import/typescript", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "tsconfig.json", | ||
sourceType: "module", | ||
}, | ||
plugins: [ | ||
"@typescript-eslint", | ||
"import", | ||
], | ||
rules: { | ||
"@typescript-eslint/adjacent-overload-signatures": "error", | ||
"@typescript-eslint/no-empty-function": "error", | ||
"@typescript-eslint/no-empty-interface": "warn", | ||
"@typescript-eslint/no-floating-promises": "error", | ||
"@typescript-eslint/no-namespace": "error", | ||
"@typescript-eslint/no-unnecessary-type-assertion": "error", | ||
"@typescript-eslint/prefer-for-of": "warn", | ||
"@typescript-eslint/triple-slash-reference": "error", | ||
"@typescript-eslint/unified-signatures": "warn", | ||
"comma-dangle": ["error", "always-multiline"], | ||
"constructor-super": "error", | ||
eqeqeq: ["warn", "always"], | ||
"import/no-deprecated": "warn", | ||
"import/no-extraneous-dependencies": "error", | ||
"import/no-unassigned-import": "warn", | ||
"no-cond-assign": "error", | ||
"no-duplicate-case": "error", | ||
"no-duplicate-imports": "error", | ||
"no-empty": [ | ||
"error", | ||
{ | ||
allowEmptyCatch: true, | ||
}, | ||
], | ||
"no-invalid-this": "error", | ||
"no-new-wrappers": "error", | ||
"no-param-reassign": "error", | ||
"no-redeclare": "error", | ||
"no-sequences": "error", | ||
"no-shadow": [ | ||
"error", | ||
{ | ||
hoist: "all", | ||
}, | ||
], | ||
"no-throw-literal": "error", | ||
"no-unsafe-finally": "error", | ||
"no-unused-labels": "error", | ||
"no-var": "warn", | ||
"no-void": "error", | ||
"prefer-const": "warn", | ||
}, | ||
settings: { | ||
jsdoc: { | ||
tagNamePreference: { | ||
returns: "return", | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Compiled JavaScript files | ||
**/*.js | ||
**/*.js.map | ||
|
||
# Except the ESLint config file | ||
!.eslintrc.js | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Node.js dependency directory | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "functions", | ||
"scripts": { | ||
"lint": "eslint \"src/**/*\"", | ||
"build": "tsc", | ||
"serve": "npm run build && firebase emulators:start --only functions", | ||
"shell": "npm run build && firebase functions:shell", | ||
"start": "npm run shell", | ||
"deploy": "firebase deploy --only functions", | ||
"logs": "firebase functions:log" | ||
}, | ||
"engines": { | ||
"node": "12" | ||
}, | ||
"main": "lib/index.js", | ||
"dependencies": { | ||
"firebase-admin": "^9.2.0", | ||
"firebase-functions": "^3.11.0", | ||
"ssr-functions": "file:../dist/sample" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^3.9.1", | ||
"@typescript-eslint/parser": "^3.8.0", | ||
"eslint": "^7.6.0", | ||
"eslint-plugin-import": "^2.22.0", | ||
"typescript": "^3.8.0", | ||
"firebase-functions-test": "^0.2.0" | ||
}, | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as functions from 'firebase-functions'; | ||
|
||
// // Start writing Firebase Functions | ||
// // https://firebase.google.com/docs/functions/typescript | ||
// | ||
// export const helloWorld = functions.https.onRequest((request, response) => { | ||
// functions.logger.info("Hello logs!", {structuredData: true}); | ||
// response.send("Hello from Firebase!"); | ||
// }); | ||
|
||
// @ts-ignore | ||
export const ssr = require('ssr-functions').ssr; | ||
|
||
export const yada = functions.https.onCall(() => { | ||
return { time: new Date().getTime() }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"outDir": "lib", | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "es2017" | ||
}, | ||
"compileOnSave": true, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FunctionsComponent } from './functions.component'; | ||
|
||
describe('FunctionsComponent', () => { | ||
let component: FunctionsComponent; | ||
let fixture: ComponentFixture<FunctionsComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ FunctionsComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FunctionsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { AngularFireFunctions } from '@angular/fire/functions'; | ||
import { EMPTY, Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-functions', | ||
template: ` | ||
<p> | ||
Functions! | ||
{{ response$ | async | json }} | ||
<button (click)="request()">Call!</button> | ||
</p> | ||
`, | ||
styles: [] | ||
}) | ||
export class FunctionsComponent implements OnInit { | ||
|
||
response$: Observable<any>; | ||
|
||
constructor(public readonly functions: AngularFireFunctions) { | ||
this.response$ = EMPTY; | ||
} | ||
|
||
ngOnInit(): void {} | ||
|
||
request() { | ||
this.response$ = this.functions.httpsCallable('yada', { timeout: 3 })({}); | ||
} | ||
|
||
} |
Oops, something went wrong.