Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 #4

Merged
merged 6 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ lerna-debug.log*
!.vscode/launch.json
!.vscode/extensions.json

package-lock.json
package-lock.json
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
RELEASE 1.0.0
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2021-04-22

### Fixed

- Changed name of exported module. Now it's the same in documentation and module: `FirebaseAdminModule`

### Changed

- Updated NestJS dependencies
- Updated `firebase-admin` dependecy
- Updated scripts. Now it's using [Nest Cli](https://docs.nestjs.com/cli/overview)

[2.0.0]: https://github.com/tfarras/nestjs-firebase-admin/releases/tag/2.0.0
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Code Style

We use [Prettier](https://prettier.io/) and tslint to maintain code style and best practices.
We use [Prettier](https://prettier.io/) and eslint to maintain code style and best practices.
Please make sure your PR adheres to the guides by running:

```bash
Expand Down
5 changes: 0 additions & 5 deletions nest-cli.json

This file was deleted.

83 changes: 46 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tfarras/nestjs-firebase-admin",
"version": "1.0.0",
"version": "2.0.1-rc.2",
"description": "NestJS Module for Firebase Admin SDK",
"author": "Taimoor Farras <[email protected]>",
"readmeFilename": "README.md",
Expand All @@ -10,21 +10,15 @@
"dist/**/*",
"*.md"
],
"scripts": {
"start:dev": "tsc -w",
"build": "tsc",
"prepare": "npm run build",
"format": "prettier --write \"src/**/*.ts\"",
"lint": "tslint -p tsconfig.json -c tslint.json",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"homepage": "https://github.com/tfarras/nestjs-firebase-admin#readme",
"keywords": [
"node.js",
"nestjs",
"nest",
"google",
"firebase",
"firebase-admin",
"module",
"sdk"
],
"publishConfig": {
Expand All @@ -37,33 +31,45 @@
"bugs": {
"url": "https://github.com/tfarras/nestjs-firebase-admin/issues"
},
"homepage": "https://github.com/tfarras/nestjs-firebase-admin#readme",
"peerDependencies": {
"@nestjs/common": "^6.0.0",
"firebase-admin": "^8.10.0"
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"firebase-admin": "^8.10.0"
"firebase-admin": "^9.6.0"
},
"devDependencies": {
"@nestjs/common": "^6.0.0",
"@nestjs/core": "^6.0.0",
"@nestjs/platform-express": "^6.0.0",
"@nestjs/testing": "6.1.1",
"@types/express": "4.16.1",
"@types/jest": "24.0.11",
"@types/node": "11.13.4",
"@types/supertest": "2.0.7",
"rxjs": "^6.5.4",
"jest": "24.7.1",
"prettier": "1.17.0",
"supertest": "4.0.2",
"ts-jest": "24.0.2",
"ts-node": "8.1.0",
"tsc-watch": "2.2.1",
"tsconfig-paths": "3.8.0",
"tslint": "5.16.0",
"typescript": "3.7.2"
"@nestjs/cli": "^7.6.0",
"@nestjs/schematics": "^7.3.0",
"@nestjs/testing": "^7.6.15",
"@types/express": "^4.17.11",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.36",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"supertest": "^6.1.3",
"ts-jest": "^26.5.4",
"ts-loader": "^8.0.18",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.3"
},
"jest": {
"moduleFileExtensions": [
Expand All @@ -72,11 +78,14 @@
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
23 changes: 14 additions & 9 deletions src/firebase-admin.module.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import { Global, Module, DynamicModule } from '@nestjs/common';
import { FirebaseAdminModuleAsyncOptions } from './firebase-admin.interface';
import { FIREBASE_ADMIN_MODULE_OPTIONS, FIREBASE_ADMIN_INJECT } from './firebase-admin.constant';
import * as admin from 'firebase-admin';
import { Global, Module, DynamicModule } from "@nestjs/common";
import { FirebaseAdminModuleAsyncOptions } from "./firebase-admin.interface";
import {
FIREBASE_ADMIN_MODULE_OPTIONS,
FIREBASE_ADMIN_INJECT,
} from "./firebase-admin.constant";
import * as admin from "firebase-admin";

@Global()
@Module({})
export class FirebaseAdminCoreModule {
export class FirebaseAdminModule {
static forRoot(options: admin.AppOptions): DynamicModule {
const firebaseAdminModuleOptions = {
provide: FIREBASE_ADMIN_MODULE_OPTIONS,
useValue: options,
};

const app = admin.apps.length === 0 ? admin.initializeApp(options) : admin.apps[0];
const app =
admin.apps.length === 0 ? admin.initializeApp(options) : admin.apps[0];

const firebaseAuthencationProvider = {
provide: FIREBASE_ADMIN_INJECT,
useValue: app,
};

return {
module: FirebaseAdminCoreModule,
module: FirebaseAdminModule,
providers: [firebaseAdminModuleOptions, firebaseAuthencationProvider],
exports: [firebaseAdminModuleOptions, firebaseAuthencationProvider],
};
Expand All @@ -36,15 +40,16 @@ export class FirebaseAdminCoreModule {
const firebaseAuthencationProvider = {
provide: FIREBASE_ADMIN_INJECT,
useFactory: (opt: admin.AppOptions) => {
const app = admin.apps.length === 0 ? admin.initializeApp(opt) : admin.apps[0];
const app =
admin.apps.length === 0 ? admin.initializeApp(opt) : admin.apps[0];

return app;
},
inject: [FIREBASE_ADMIN_MODULE_OPTIONS],
};

return {
module: FirebaseAdminCoreModule,
module: FirebaseAdminModule,
imports: options.imports,
providers: [firebaseAdminModuleOptions, firebaseAuthencationProvider],
exports: [firebaseAdminModuleOptions, firebaseAuthencationProvider],
Expand Down
12 changes: 5 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": false,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"baseUrl": "./",
"noLib": false
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
"incremental": true
}
}
18 changes: 0 additions & 18 deletions tslint.json

This file was deleted.